i have update view users update profiles. keep getting error:
noreversematch @ /user/2/edit reverse 'user_profile' no arguments not found. 1 pattern(s) tried: ['user/(?p<pk>\\d+)/$']
nothing i've tried working (adding pk, etc.).
the updateview:
class usereditprofileview(loginrequiredmixin,updateview): login_url = '/login/' model = userprofile fields = [ 'first_name', 'profile_pic', 'location', 'title', 'user_type', 'website', 'about', 'twitter', 'dribbble', 'github' ] template_name_suffix = '_edit_form' success_url = reverse_lazy('users:user_profile')
app urls:
from django.conf.urls import url users import views app_name = 'users' urlpatterns = [ url(r'^$',views.userlistview.as_view(),name='user_list'), url(r'^(?p<pk>\d+)/$',views.detailprofile,name='user_profile'), url(r'^(?p<pk>\d+)/edit$',views.usereditprofileview.as_view(),name='user_profile_edit'), url(r'^login/$',views.user_login,name='user_login'), url(r'^logout/$',views.user_logout,name='user_logout'), url(r'^register/$',views.register,name='register'), ]
edit profile template:
{% extends "users/base.html" %} {% block content %} <div class="form-base"> <h2>edit profile</h2> <form method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="save" /> </form> </div> {% endblock %}
let me know if need see else.
you need provide pk
in user_profile
class usereditprofileview(loginrequiredmixin,updateview): login_url = '/login/' model = userprofile fields = [ 'first_name', 'profile_pic', 'location', 'title', 'user_type', 'website', 'about', 'twitter', 'dribbble', 'github' ] template_name_suffix = '_edit_form' def get_success_url(self): userid = self.kwargs['pk'] return reverse_lazy('users:user_profile', kwargs={'pk': userid})
Comments
Post a Comment