疑問
djangoでパスワード変更を作成しているのですが
URLでaccounts/password_changeとすると
templateの表示がdjangoの管理の変更画面が出てきます。
ですがurlを少しでも変更すると自作したtemplateの表示になります。
accounts/password_changeでも自作したものには出来ないんでしょうか。
こちらのサイトを参考にしています。
url
1 path('password_change/', views.PasswordChange.as_view(), name='password_change'), #管理画面 2#path('password_chan/', views.PasswordChange.as_view(), name='password_change'), #自作したtemplateになる 3 path('password_change/done/',views.PasswordChangeDone.as_view(),name='password_change_done'),
view
1class PasswordChange(LoginRequiredMixin,PasswordChangeView): 2 """パスワード変更ビュー""" 3 form_class = forms.MyPasswordChangeForm 4 success_url = reverse_lazy('accounts:password_change_done') 5 template_name = 'accounts/password_change.html' 6 7 8class PasswordChangeDone(LoginRequiredMixin,PasswordChangeDoneView): 9 """パスワード変更しました""" 10 template_name = 'accounts/password_change_done.html'
forms
1 2class MyPasswordChangeForm(PasswordChangeForm): 3 """パスワード変更フォーム""" 4 5 def __init__(self, *args, **kwargs): 6 super().__init__(*args, **kwargs) 7 for field in self.fields.values(): 8 field.widget.attrs['class'] = 'form-control'
回答1件
あなたの回答
tips
プレビュー