第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

注銷反向網(wǎng)址不適用于下一頁

注銷反向網(wǎng)址不適用于下一頁

慕姐4208626 2023-02-15 15:04:30
在我看來,我正在檢查擁有特定電子郵件地址的用戶是否是經(jīng)過身份驗證的用戶。如果沒有,我想重定向到注銷,然后使用相同的 URL 登錄。這是我的觀點:class VerifyUserEmailAddressView(LoginRequiredMixin, SingleObjectMixin, generic.View):    model = UserEmailAddress    success_url = reverse_lazy('accounts:edit_profile_emails')    def get(self, request, *args, **kwargs):        email_address = self.get_object()        if (not (email_address.user == self.request.user)):            return redirect(to='accounts:logout', **{'next_page': self.request.get_full_path()}) # This is the line that causes the exception.        assert (email_address.user == self.request.user)        ...這是我的注銷視圖:class LogoutView(django_auth_views.LogoutView):    template_name = 'accounts/logged_out.html'但問題是,我得到一個例外:django.urls.exceptions.NoReverseMatch: Reverse for 'logout' with keyword arguments '{'next_page': '/edit-profile/emails/95209103364882328130/verify/64435189922652686051/'}' not found. 1 pattern(s) tried: ['logout\\/$']urls.py:urlpatterns = [    path(route='login/', view=views.LoginView.as_view(), name='login'),    path(route='logout/', view=views.LogoutView.as_view(), name='logout'),    path(route='edit-profile/emails/', view=views.EditProfileEmailsView.as_view(), name='edit_profile_emails'),    path(route='edit-profile/emails/<digits:pk>/verify/<str:token>/', view=views.VerifyUserEmailAddressView.as_view(), name='verify_email'),]我該如何解決這個問題?
查看完整描述

1 回答

?
嚕嚕噠

TA貢獻(xiàn)1784條經(jīng)驗 獲得超7個贊

我假設(shè)next_page是URL 查詢參數(shù)而不是URL 參數(shù)


如果是這樣,您必須生成一個類似于以下內(nèi)容的 URL,


/account/logout/?next=/foo/bar/somewhere/

為此,請將您的重定向語句替換為,


from django.urls import reverse


return redirect('{}?next={}'.format(reverse('accounts:logout'), self.request.get_full_path()))



查看完整回答
反對 回復(fù) 2023-02-15
  • 1 回答
  • 0 關(guān)注
  • 97 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號