Monday, November 26, 2012

Re: overwrite field value in subclasses

Hi,

Thank for the reply.

Digging into _meta.fields of a created instance I see, as you said that myfield is still defined as in the upper class.

If I understood correctly your answer sub-class should have the field "redefine" instead of assigned .
something like 
myfield = models.PositiveSmallIntegerField(editable=False,default=UpperAbstract.CHOICE_A)

doing this , model validation raise a fieldRerror exception arguing that I am not allowed to do that because a field with the same
name already exists.

Did I misunderstood your comment ?

thx
manu





--
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/-/uiRCDcmeFswJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment