0👍
✅
Time for answer then:
def text1():
for r in Supervision.objects.all():
try:
x = Facility.objects.filter(code1=r.code1, code2=r.code2).distance(r.point).order_by('distance')[:1].get()
r.facilityName = x.facilityName
r.save()
print x.primary_name
except ObjectDoesNotExist:
print 'Does Not Exist!'
pass
Source:stackexchange.com