Django DoesNotExist
This line
except Vehicle.vehicledevice.device.DoesNotExist
means look for device instance for DoesNotExist exception, but there's none, because it's on class level, you want something like
except Device.DoesNotExist
I have found the solution to this issue using ObjectDoesNotExist on this way
from django.core.exceptions import ObjectDoesNotExist......try: # try somethingexcept ObjectDoesNotExist: # do something
After this, my code works as I need
Thanks any way, your post help me to solve my issue
The solution that i believe is best and optimized is:
try: #your codeexcept "ModelName".DoesNotExist: #your code