Reputation: 5
I have defined my UserDetail model, which has one to one relation with User.
class UserDetail(models.Model):
user = models.OneToOneField(User)
....
but when I am trying to access UserDetail object through request.user in my view it is throwing me error as "User has no userdetail.".
form = UpdateProfile(request.user.userdetail)
while I am able to use user.userdetail in Django shell. I have no idea why it is happening, is request.user have some differences with User object?
Upvotes: 0
Views: 207
Reputation: 599778
No. It is because that particular user does not have an associated UserDetail instance.
Upvotes: 3