I noticed a strange behavior with Django and filed a bug
https://code.djangoproject.com/ticket/19271#ticket

It is suggested that I first check on the support group if the bug is valid 
or not. Fair Enough.

I have created a standalone project to demonstrate the problem. In order to 
run it you may have to create a database and configure it in settings.py 
though.
Code that does not work:
https://github.com/iamrohitbanga/django_ticket_19271/tree/code_not_working

Code that works:
https://github.com/iamrohitbanga/django_ticket_19271/tree/code_working

Just creating my_id field in BaseModel class with unique=True set causes 
the code to fail with the stack trace below.
My usecase is a bit weird hence you would find model form inheriting from 
abstract models. IMHO that should not matter. The code works without unique 
fields but does not work with non-unique fields. I will be happy to provide 
more clarifications.

Below is the stacktrace for the 
"AttributeError at /create_new type object 'BaseModel' has no attribute 
'_default_manager' Traceback: File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in 
get_response 111. response = callback(request, *callback_args, 
**callback_kwargs) File "django_bug_19271/testproj/testproj/views.py" in 
create_new 33. if form.is_valid(): File 
"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in is_valid 
124. return self.is_bound and not bool(self.errors) File 
"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in 
_get_errors 115. self.full_clean() File 
"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in 
full_clean 272. self._post_clean() File 
"/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in 
_post_clean 338. self.validate_unique() File 
"/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in 
validate_unique 347. self.instance.validate_unique(exclude=exclude) File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in 
validate_unique 633. errors = self._perform_unique_checks(unique_checks) 
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in 
_perform_unique_checks 717. qs = 
model_class._default_manager.filter(**lookup_kwargs) Exception Type: 
AttributeError at /create_new Exception Value: type object 'BaseModel' has 
no attribute '_default_manager' Request information: GET: No GET data POST: 
csrfmiddlewaretoken = u'**********' my_id = u'1' name = u'Rohit' FILES: No 
FILES data COOKIES: csrftoken = '****' 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IpjAFDReTPwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to