views.py爲什麼我在get_absolute_url方法得到反向匹配錯誤 - ?Django的
class ProfileView(DetailView):
model = User
template_name ="profile/profile_view.html"
class ProfileEdit(UpdateView):
model = User
form_class = ProfileForm
template_name="profile/profile_new.html"
models.py
#.... models
def get_absolute_url(self):
return reverse('user:user_profile', kwargs={ "slug": self.slug })
urls.py
url(r'^(?P<slug>[\[email protected]+-]+)/edit/$', ProfileEdit.as_view(), name='profile_edit'),
url(r'^(?P<slug>[\[email protected]+-]+)/$', ProfileView.as_view(), name='user_profile'),
反向的「 user'profile'帶有參數'()'和關鍵字參數'{'slug':'rahul'}'找不到。 0模式嘗試:[]
我不明白我得到正確的slug值,但什麼是正確的方式來傳遞它的url模式?
是在安裝的應用程序設置,包括那些網址,您的應用程序? – Sayse
是的!詳細視圖和更新視圖都可以正常工作..在更新視圖中的發佈請求之後,我想重定向到detailview – Rahul
並且'user'命名空間肯定存在? (請包括相關的基地址) – Sayse