python - Reverse relation (one-to-one) lookup not working in Django view (django-plans) -
I have just installed django-plans . They link an UserPlan object to the settings used. Youth_USER_MODEL through one-to-one relationship. As I think, there is no relation required for reverse lookup. Therefore, without the caps, the class name should be able to use, e.g. userplan .
My problem is that the reverse lookup works in the Dragon Shell:
gt; & Gt; From profiles Model Import Custom User & gt; & Gt; & Gt; S = CustomUser.objects.get (email = "test@test.com") & gt; & Gt; & Gt; S & lt; Custom User: test@test.com> & Gt; & Gt; & Gt; S.userplan & lt; UserPlan: test@test.com [starter] & gt; But when I use code in a view, it returns a attribute error :
'customUser 'Object is not attribute' User Plan ' This is the code that I am using in this view:
u = CustomUser.objects.get (Email = "test @ Test.com") up = u.userplan I thought it was to do with request.user SimpleLazyObject, but Even the "real" user was not working to see it.
Any suggestions?
PS As you can see, we are using a custom user model.
Comments
Post a Comment