I have now code like below and I have message. I try split success_url with
id number and compare it with urls.py
AttributeError at /users/login/
>
> 'int' object has no attribute 'get'
>
>
views.py
class LoginView(FormView):
template_name = 'login_form.html'
model = MysiteUser
form_class = AuthenticationForm
def form_valid(self, form):
x = form.get_user_id()
return x
def get_success_url(self):
x = self.x
success_url = '/users/profile/{}'.format(x)
return success_url
W dniu piątek, 29 kwietnia 2016 09:36:30 UTC+2 użytkownik Dariusz Mysior
napisał:
>
> I use FormView do login user, but I don't know how I should add his ID
> number to success url that when he will log in adres will be
> users/profile/id
>
> urls.py
>
> from users.views import RegisterView, LoginView, ProfileView
>
> urlpatterns = [
>
> url(r'^register/$', RegisterView.as_view(), name='register-view'),
> url(r'^login/$', LoginView.as_view(), name='login-view'),
> url(r'^profile/(?P<pk>\d+)/$', ProfileView.as_view(),
> name='profile-view'),
>
>
>
> views.py
>
> class LoginView(FormView):
> template_name = 'login_form.html'
> model = MysiteUser
> form_class = AuthenticationForm
> success_url = '/users/profile/'
>
>
urls.py
from django.conf.urls import url
from users.views import RegisterView, LoginView, ProfileView
urlpatterns = [
url(r'^register/$', RegisterView.as_view(), name='register-view'),
url(r'^login/$', LoginView.as_view(), name='login-view'),
url(r'^profile/(?P<id>[0-9]+)/$', ProfileView.as_view(),
name='profile-view'),
]
--
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/361d6987-cf65-476b-a6c1-673a6e37f80a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.