Skip to content

Instantly share code, notes, and snippets.

@azpwnz
Last active May 9, 2017 07:13
Show Gist options
  • Save azpwnz/9ba5dec7aef2bd6323d5da3aa1de323b to your computer and use it in GitHub Desktop.
Save azpwnz/9ba5dec7aef2bd6323d5da3aa1de323b to your computer and use it in GitHub Desktop.
The way to check whether object has ManyToMany or OneToOne field in Django
if hasattr(object, 'some_field'):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment