Hallo,

I have a problem running Django's full_validation-method upon an instance of an inherited model. Please consider the following two models:

class ParentModel(models.Model):

    parent_model_id = models.IntegerField(primary_key=True)
    parent_model_attr = models.CharField(max_length=200)


class ChildModel(ParentModel):

    child_model_attr = models.CharField(max_length=200)

Creating a ChildModel by using the keyword pk instead of the primary key's real attribute name and running full_validation on it before saving (after saving this method does not make much sense, I think) leads to an error as shown below:

>>> from mytest.models import ChildModel

>>> cm = ChildModel(pk=1,child_model_attr='some text',parent_model_attr='Some other text')

>>> cm.full_clean()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 824, in full_clean
    raise ValidationError(errors)
ValidationError: {'parent_model_id': [u'This field cannot be null.']}


Using the primary key's real attribute name works of course (but cannot be done in my scenario).

Any ideas how to make using the pk-keyword work without that validation error?

Thanks in advance for any hint.


With best regards

Carsten Reimer


--
Carsten Reimer
Web Developer
carsten.rei...@galileo-press.de
Phone +49.228.42150.73

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Phone +49.228.42150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Managing Directors: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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