I am using it as if ModelName.objects.get(fieldname=value).exists():
I either get the error 'ModelName' object has no attribute 'exists' or it throws a DoesNotExist
exception.
Related doc: https://docs.djangoproject.com/en/1.10/ref/models/querysets/#django.db.models.query.QuerySet.exists
You should apply it to queryset, not a single object, try:
if ModelName.objects.filter(fieldname=value).exists():
If queryset is not empty, this will return True
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments