On Fri, Apr 29, 2016 at 01:12:23AM -0700, Dariusz Mysior wrote:
> Hi I try learn Django, and I want do authenticated system in CBV. My nxt 
> try is that I wright it like below but in url adrees instead of id number I 
> have "None" :/
> 
>  success_url = '/users/profile/'+ str(MysiteUser.pk)

That won't work – the class definition of LoginView is evaluated
during import, not when processing a request, which means you cannot
use the “current user” object in the definition of a class attribute.

Is there any reason why you cannot use one of the two solutions I
described in my previous email? (Quoted below.)

On Fri, Apr 29, 2016 at 10:03:15AM +0200, Michal Petrucha wrote:
> personally, I'd set up an additional view with a URL pattern of
> '^profile/$' that would just get the current logged-in user, and
> return a redirect to the user's profile page.
> 
> Or even better, if you do not need users to be able to view other
> users' profiles, you can just remove the user ID from your profile URL
> pattern, and simply always display the current user's profile there.

Cheers,

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160429084354.GF435%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to