[Answered ]-Django model unit test

2👍

Although the test client starts from a blank database each time, that’s no reason to assume that the primary key is 1; sequences are not reset when the tables are emptied after each run. Instead of explicitly getting pk=1, you should just query for the first item:

 user = UserProfile.objects.first()

Leave a comment