私は非常に単純な ModelForm サブクラスを持っています:
class UserPrefsForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name','last_name','username']
ビューにフォームを保存しようとすると (ここではポスト関数のみ):
def post(self, request):
userform = UserPrefsForm(request.POST)
context = self.get_context_data()
if userform.is_valid():
userform.save()
else:
context['errors'] = True
return render(request,self.template_name,context)
このエラーが発生しました:
AttributeError at /prefs
'super' object has no attribute 'error_messages'
Traceback:
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/braces/views.py" in dispatch
107. request, *args, **kwargs)
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
86. return handler(request, *args, **kwargs)
File "/home/tonjo/prj/tuned_prj/tuned_django/graph/views.py" in post
147. if userform.is_valid():
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/forms/forms.py" in is_valid
126. return self.is_bound and not bool(self.errors)
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/forms/forms.py" in _get_errors
117. self.full_clean()
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/forms/forms.py" in full_clean
274. self._post_clean()
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/forms/models.py" in _post_clean
344. self.validate_unique()
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/forms/models.py" in validate_unique
353. self.instance.validate_unique(exclude=exclude)
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/db/models/base.py" in validate_unique
731. errors = self._perform_unique_checks(unique_checks)
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/db/models/base.py" in _perform_unique_checks
831. errors.setdefault(key, []).append(self.unique_error_message(model_class, unique_check))
File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/db/models/base.py" in unique_error_message
882. return field.error_messages['unique'] % {
File "/home/tonjo/venv/tuned/src/neo4django/neo4django/utils.py" in __getattr__
303. return getattr(target, name)
不足していることは理解していerror_messages
ます...それらを定義することを余儀なくされていますか?