2👍
✅
First, I think you’ll be happier of you explicitly make your PK’s into integers.
loc = Location.objects.get(pk=int(attrs['location']))
Second, you should use a Form.
-
It validates the fields for you.
-
It will create the Model object from the Form object.
Read this. http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/
Source:stackexchange.com