私はDjango
に新規で、Django 1.11でアプリケーションを書いています。Djangoはauthユーザープロフィールを編集します
私はProfile update
ページを作成します。
私は127.0.0.1:8000/accounts/update
にアクセスすると、それは
AttributeError at /accounts/update/
Generic detail view UpdateProfile must be called with either an object pk or a slug.
を与えるすべてのプロファイルに関連する活動を管理するためのアプリ
accounts
を作成し、
from django.contrib.auth.models import User
# Create your views here.
from django.views.generic import TemplateView, UpdateView
class ProfileView(TemplateView):
template_name = 'accounts/profile.html'
class ChangePasswordView(TemplateView):
template_name = 'accounts/change_password.html'
class UpdateProfile(UpdateView):
model = User
fields = ['first_name', 'last_name']
template_name = 'accounts/update.html'
とmyapp/accounts/urls.py
from django.conf.urls import url
from . import views
app_name = 'accounts'
urlpatterns = [
url(r'^$', views.ProfileView.as_view(), name='profile'),
url(r'^profile/', views.ProfileView.as_view(), name='profile'),
url(r'^change_password/', views.ChangePasswordView.as_view(), name='change_password'),
url(r'^update/', views.UpdateProfile.as_view(), name='update'),
url(r'^setting/', views.SettingView.as_view(), name='setting')
]
でクラスを作成しました
以来、私はログに記録したいプロフィール情報を編集するためにユーザに表示されます。私はURLにpk
を渡したくありません。ジャンゴ1.11でプロフィール更新ページを作成する方法
?
私はこの作業を取得します。しかし、データを更新したかどうかに基づいてユーザーをリダイレクトする方法。私は、そのデータが更新され、リダイレクトURLを求めていることがわかります。 –
どういう意味ですか?更新後にユーザーをリダイレクトしたい場合(または理解していない場合)はどこにリダイレクトしますか?それが長いものであれば、別の質問をして、あなたの問題に対するこの1つの答えを考えてみてください。 – Bestasttung
新しい質問が投稿されましたhttps://stackoverflow.com/q/46193057/3719167 –