Code that works:
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 = '****'