[Answered ]-Use request's user informations in tests

0👍

I have found the problem !

user = User.objects.create_user(username=username, password=password)
user.userprofile.status = status
user.save()

When I do that, i suppose user = User.objects.create_user(username=username, password=password)returns an user (false).

So, I have to make a request :

user = User.objects.create_user(username=username, password=password)
test = UserProfile.objects.filter(user=username)
test.status = status
test.save()

And it is ok !

2👍

Your definition of your status field is incorrect.
CharFields require a “max_length” attribute that is a positive integer.

Change it to the following:

models.CharField(max_length=..., choices=STATUS_CHOICES)

See also here

Leave a comment