I am writing my views.py, in which i need to get the model instance by following code:
model_instance = AlertCount.objects.get(user=request.user.username)
But at the first time after running python manage.py syncdb. The field of table is initially empty. So it shows this error
DoesNotExist: AlertCount matching query does not exist
It should be obvious. But according to my views.py method, Event if this error occurred it continue to execute the method after passing 0 to all of the fields to this model instance.
If I understand correctly you want to do something like this: