Foo.myfield is 0, but when you created a new models.Field object in the 
abstract class, it did some deep magic. There’s also Foo._meta.fields which has 
the old myfield in it. The only thing you can do is create a new myfield with 
default=0 and editable=False.

On Nov 23, 2012, at 8:40 AM, Emmanuel Jannetti wrote:

> Hi all,
> 
> One piece of my model is as follow :
> 
> class UpperAbstract(models.Model):
>   CHOICE_A = 0
>   CHOICE_B = 1
>   CHOICE_C = 2
>   myfield = 
> models.PositiveSmallIntegerField(choices=((CHOICE_A,'A'),(CHOICE_B,"B"),(CHOICE_C,"C")),blank=False)
>   class Meta:
>       abstract = True
> 
> class Foo(UpperAbstract):
>       myfield = UpperAbstract.CHOICE_A
> 
> 
> 
> I am expecting any instance of Foo being created, to have 'myfield' always 
> and "automatically" set to UpperAbstract.CHOICE_A
> In my test the created object as null value and saving it is refused on 
> IntegrityError because 'myfield' cannot be None
> 
> thank in advance for any help.
> regards
> 
> manu
> 

Peter of the Norse
rahmc...@radio1190.org



-- 
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