1👍
✅
Try using the ids of the user
and category
, instead of the actual objects.
t_listing = {
'title': 'Test',
'email': 'test@test.com',
'phone_number': '4057081902',
'description': 'Test',
'category': category.id,
'user': user.id,
}
Note that get_or_create
returns a tuple, so you should change that line to:
category, created = Category.objects.get_or_create(name='test')
Source:stackexchange.com