Django Admin Console giving 'str' object has no attribute '__iter__' error - django

I am trying to make some changes in the fields using Djangos build in Admin console.It gives me 'str' object has no attribute 'iter' error exception when i try to change some fields in the models.These fields are Foreign Keys
PROJECT MODEL CAUSES ERROR WHEN I CHANGE THE MANAGER FIELD
class Project(models.Model):
"""Project Model.
"""
name = models.CharField(unique=True, max_length=255)
manager = models.ForeignKey('Employee', blank=True, null=True)
project = models.Manager()
class Employee(models.Model):
"""
Employee Model.
"""
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.CharField(
unique=True,
max_length=255,
blank=True,
null=True)
projects = models.ManyToManyField('Project', blank=True)
employee = models.Manager()
TRACEBACK
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
544. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
211. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in change_view
1512. return self.changeform_view(request, object_id, form_url, extra_context)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in inner
185. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in changeform_view
1451. change_message = self.construct_change_message(request, form, formsets, add)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in inner
185. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in construct_change_message
942. elif form.changed_data:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in __get__
35. res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in changed_data
447. if field.has_changed(initial_value, data_value):
File "/usr/local/lib/python2.7/dist-packages/django/forms/fields.py" in has_changed
1075. initial = field.to_python(initial)
File "/usr/local/lib/python2.7/dist-packages/django/forms/fields.py" in to_python
424. return super(DateField, self).to_python(value)
File "/usr/local/lib/python2.7/dist-packages/django/forms/fields.py" in to_python
395. for format in self.input_formats:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in __wrapper__
112. return getattr(res, method_name)(*args, **kw)
Exception Type: AttributeError at /admin/login/project/2/change/
Exception Value: 'str' object has no attribute '__iter__'
admin.py file
from django.contrib import admin
from models import *
admin.site.register(Employee)
admin.site.register(Project)

I've had this problem myself. I upgraded from Django 1.10 to 1.10.2 and that seems to have fixed it for me. Good luck.

Related

Django Admin - 'bool' object is not callable

When I try and delete records within Django Admin, for some records, I am getting
'bool' object is not callable
I cannot work out where the error is based on this Traceback.
Traceback:
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/contrib/admin/options.py" in wrapper
575. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/contrib/admin/sites.py" in inner
223. return view(request, *args, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
62. return bound_func(*args, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
58. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/contrib/admin/options.py" in delete_view
1736. return self._delete_view(request, object_id, extra_context)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/contrib/admin/options.py" in _delete_view
1760. [obj], opts, request.user, self.admin_site, using)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/contrib/admin/utils.py" in get_deleted_objects
131. collector.collect(objs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/contrib/admin/utils.py" in collect
195. return super().collect(objs, source_attr=source_attr, **kwargs)
File "/home/henry/Documents/Sites/Development/django-authenticjobs/env/lib/python3.6/site-packages/django/db/models/deletion.py" in collect
222. field.remote_field.on_delete(self, field, sub_objs, self.using)
Exception Type: TypeError at /admin/jobboard/job/155/delete/
Exception Value: 'bool' object is not callable
Can anyone suggest where to look? Thank you
You have set an on_delete of a ForeignKey, or OneToOneField to a boolean (True or False). So something like:
class SomeModel(models.Model):
some_fk = models.ForeignKey(OtherModel, on_delete=False)
You can not set this to a boolean. You can set this to the values listed in the documentation: CASCADE, PROTECT, SET_NULL, SET_DEFAULT, SET(..), or DO_NOTHING.
You could, strictly speaking, implement your own strategy as well, since the ones listed above are in fact just functions. For example the CASCADE is implemented like [GitHub]:
def CASCADE(collector, field, sub_objs, using):
collector.collect(sub_objs, source=field.remote_field.model,
source_attr=field.name, nullable=field.null)
if field.null and not connections[using].features.can_defer_constraint_checks:
collector.add_field_update(field, None, sub_objs)
although likely you do not need to implement your own, and pick one of the ones listed in the documentation. For example:
class SomeModel(models.Model):
some_fk = models.ForeignKey(OtherModel, on_delete=models.CASCADE)

overriding empty_value_display for specified field not working in django Admin

I have written a model as follows:
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
title = models.CharField(max_length=3)
birth_date = models.DateField(blank=True, null=True)
And my modeladmin is as follows:
from django.contrib import admin
class AuthorAdmin(admin.ModelAdmin):
fields = ('name', 'title', 'view_birth_date')
def view_birth_date(self, obj):
return obj.birth_date
view_birth_date.empty_value_display = '-empty-'
As documented in django 2.1 https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.empty_value_display, I am trying to do this but its not working.
Its gives me fielderror. Even I didn't understand its purpose.
My traceback:
Traceback (most recent call last):
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\options.py", line 703, in get_form
return modelform_factory(self.model, **defaults)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\forms\models.py", line 551, in modelform_factory
return type(form)(class_name, (form,), form_class_attrs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\forms\models.py", line 266, in __new__
raise FieldError(message)
django.core.exceptions.FieldError: Unknown field(s) (view_birth_date) specified for Author
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\options.py", line 604, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\sites.py", line 223, in inner
return view(request, *args, **kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\options.py", line 1639, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\utils\decorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\utils\decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\options.py", line 1525, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\options.py", line 1554, in _changeform_view
ModelForm = self.get_form(request, obj, change=not add)
File "C:\Users\monikat\Envs\django_training\lib\site-packages\django\contrib\admin\options.py", line 707, in get_form % (e, self.__class__.__name__)
django.core.exceptions.FieldError: Unknown field(s) (view_birth_date) specified for Author. Check fields/fieldsets/exclude attributes of class AuthorAdmin.
Does anyone know why this error is coming?
The problem is that you have defined view_birth_date in the fields attribute of model admin class.
Since it is not present in your db model, it is giving error. Such custom fields will work for list_display, in which you can fetch the value from a method as you have done above, see the docs.
Now if you want some custom field to display on the add/change page , you have to create a custom form and there you can define your custom fields.
If the custom field is just for representation , you can define it as readonly as :
class AuthorAdmin(admin.ModelAdmin):
fields = ('name', 'title', 'view_birth_date')
readonly_fields = ['view_birth_date']
def view_birth_date(self, obj):
return obj.title
view_birth_date.empty_value_display = '-empty-'
Hope it helps!

save() missing 1 required positional argument: 'request' in django

I create a model:
class Person(models.Model):
name = models.CharField(max_length=250)
slug = AutoSlugField(populate_from='name')
birth_date = models.DateField(null=True, blank=True)
blood_group = models.CharField(max_length=5)
present_address = models.CharField(max_length=250, blank=True)
permanent_address = models.CharField(max_length=250, blank=True)
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
related_name='member_persons')
forms.py:
class MemberForm(ModelForm):
class Meta:
model = Person
exclude = ('user',)
def save(self, request, commit=True):
person = super().save(commit=False)
if not person.pk:
person.user = get_user(request)
if commit:
person.save()
self.save_m2m()
return person
It worked fine for first person create. When same person again try to submit create form with different data it gives 'save() missing 1 required positional argument: 'request''. Full traceback:
Traceback:
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in post
217. return super(BaseCreateView, self).post(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in post
183. return self.form_valid(form)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in form_valid
162. self.object = form.save()
Exception Type: TypeError at /person/create/
Exception Value: save() missing 1 required positional argument: 'request'
my views.py:
#require_authenticated_permission(
'member.add_person')
class PersonCreate(CreateView):
template_name = 'member/person_form.html'
model = Person
success_url = '/person/'
form_class = MemberForm
I want to show a message "You already submitted data" rather than getting this error. How can I show this message in the person creation form?
Any help will be appreciated.
Edit:
New error:
Traceback:
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in get
213. return super(BaseCreateView, self).get(request, *args, **kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in get
174. return self.render_to_response(self.get_context_data())
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in get_context_data
93. kwargs['form'] = self.get_form()
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/views/generic/edit.py" in get_form
45. return form_class(**self.get_form_kwargs())
Exception Type: TypeError at /person/create/
Exception Value: __init__() got an unexpected keyword argument 'request'
save signatrue is invalid. there shouldn't be request in arguments. if you want to pass it to form use get_form
#require_authenticated_permission('member.add_person')
class PersonCreate(CreateView):
template_name = 'member/person_form.html'
model = Person
success_url = '/person/'
form_class = MemberForm
def get_form(self, form_class=None):
form = super().get_form(form_class)
form.request = self.request
return form
And then
class MemberForm(ModelForm):
class Meta:
model = Person
exclude = ('user',)
def save(self, commit=True):
person = super().save(commit=False)
if not person.pk:
person.user = get_user(self.request)
if commit:
person.save()
self.save_m2m()
return person
I send those parameters in this way
class MemberNew(generic.CreateView):
model = Member
form_class = MemberForm
template_name = "..."
def get_form(self, form_class=None):
return MemberForm(self.request, **self.get_form_kwargs())

relation "comparison_bundle" does not exist LINE 1: SELECT COUNT(*) FROM "comparison_bundle"

It's a new database that I have just created with Postgresql.
When I go to the admin page everythin works fine except when I try to go to the "Bundle" model.
Here is the model:
class Company(models.Model):
name = models.CharField(max_length=50)
info = models.TextField()
def __str__(self):
return self.name
class Bundle(models.Model):
company = models.ForeignKey(Company, null=True)
title = models.CharField(max_length=150)
info = models.TextField(blank=True)
price = models.credit = models.DecimalField(max_digits=15, decimal_places=4, null=True)
def __str__(self):
return self.title
Admin.py:
from django.contrib import admin
from models import Company, Bundle
class BundleAdmin(admin.ModelAdmin):
fieldsets= [
('Bundles info', {'fields':['title', 'packet', 'info', 'price']}),
]
And this is what i get:
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
584. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
204. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
29. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
25. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in changelist_view
1486. self.list_max_show_all, self.list_editable, self)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/main.py" in __init__
110. self.get_results(request)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/main.py" in get_results
219. result_count = paginator.count
File "/usr/local/lib/python2.7/dist-packages/django/core/paginator.py" in _get_count
72. self._count = self.object_list.count()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in count
338. return self.query.get_count(using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in get_count
424. number = obj.get_aggregation(using=using)[None]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in get_aggregation
390. result = query.get_compiler(using).execute_sql(SINGLE)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
786. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py" in execute
81. return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /admin/comparison/bundle/
Exception Value: relation "comparison_bundle" does not exist
LINE 1: SELECT COUNT(*) FROM "comparison_bundle"
In the terminal I get this error:
[01/Dec/2014 13:45:43] "GET /admin/comparison/bundle/ HTTP/1.1" 500 211501
Could this be because I Created a new database and replaced the old database name in settings.py?
Or could it be because I deleted the migration files?
I have no clue why I get this error
First, actually, you could just simply forget to synchronize your database. If so, do it!:
python manage.py syncdb
If not, maybe you'll need to completely drop database (if you have data in it) and start over again.

Django 1.5.4 error_messages in ModelForm

I have a very simple ModelForm subclass:
class UserPrefsForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name','last_name','username']
When I try to save the form in my view (only the post function here):
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)
I got this error:
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)
I understand is the missing error_messages... Am I forced to define them?