1👍
✅
Your code will work as expected if you’re looking up a Location
by a unique identifier instead of trying to match all fields:
location, created = Location.objects.get_or_create(pk=pk)
if created:
num_of_new_locs+=1 #number of new locations increased
else:
location.url= loc_fields['url']
location.locationname = loc_fields['locationname']
location.desc = loc_fields['desc']
location.str_hnr = loc_fields['str_hnr']
location.save()
Source:stackexchange.com