2👍
✅
You need to assign an actual object. Something like the following should work:
loc = Location.objects.get(pk=1)
obj.location = loc
obj.save()
where obj
is the model you’re trying to save which has location as a foreign key.
👤ars
Source:stackexchange.com