On Fri, Apr 29, 2016 at 07:18:28AM -0700, Dariusz Mysior wrote:
> Hej ja po angielsku słabo piszę, chciałem się nauczyć Class Based View i na 
> tym zrobić system rejestracji, masz pomysł jak to dalej zrobić? Chciałbym 
> wyciagnąć pk i dodać do adresu succes_url...

Heh, Michal, nie Michał. (-: O krajinu vedľa (Slovensko).

Anyway, while I can read Polish more or less OK, I'm clueless at
writing, so I'll try this in English again.

What I suggest is that you leave your view as it was, and create
another one just to redirect the user::

    class LoginView(FormView):
        template_name = 'login_form.html'
        model = MysiteUser
        form_class = AuthenticationForm
        success_url = '/users/profile/'    


    class CurrentUserProfileView(RedirectView):
        def get_redirect_url(self):
            return reverse('profile-view', pk=self.request.user.pk)

And, of course, then you have to add it to urls.py::

    from users.views import RegisterView, LoginView, ProfileView, 
CurrentUserProfileView

    urlpatterns = [
        url(r'^register/$', RegisterView.as_view(), name='register-view'),
        url(r'^login/$', LoginView.as_view(), name='login-view'),
        url(r'^profile/$', CurrentUserProfileView.as_view(), 
name='current-profile-view'),
        url(r'^profile/(?P<pk>\d+)/$', ProfileView.as_view(), 
name='profile-view'),
    ]

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/20160429143730.GH435%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: Digital signature

Reply via email to