这是我 views.py 函数:
class ProfileUpdateView(UpdateView):
model = UserProfile
fields = ['first_name','last_name','username','gender','datetimepicker','p_photo','h_photo','subtitles','political_incline',
'about_me','birthplace','lives_in','country','province','city','occupation',
'relationship_status','website','phone_number','religious_belifs','political_incline',
'facebook','twitter','RSS','dibble','spotify']
urls.py
url(r'^updateprofile/(?P<pk>d+)/$',views.ProfileUpdateView.as_view(success_url='/postlist/')),
在视图中添加一个成功的网址,如下所示
success_url = reverse_lazy('the_page_required')
如果要转到详细信息视图,也可以以这种方式进行定义。
def get_success_url(self):
return reverse('detail_view_url', kwargs={'pk': self.pk})