Person.objects.create(name='Adam', person_type='Appellant')
Here, as the argument to person_type, the create () method expects to get an instance of person_type, not a string
So simple nationwide:
pers_type = Person_Type.objects.get(pers_type='Appelant') # assuming pers_type is unique Person.objects.create(name='Adam', pers_type=pers_type)
or, given the case where "Appellant" is not present in db:
try: pers_type = Person_Type.objects.get(pers_type='Appelant') except Person_Type.DoesNotExists: person_type = Person_Type.objects.create(pers_type='Appellant') Person.objects.create(name='Adam', pers_type=pers_type)
source share