On Nov 27, 2007 8:56 AM, Miguel Galves <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've created a slugfield, which should accept 3 values from a list
>
> STATUS = (
>         ('PUBLICADO', "Publicado"),
>         ('ESPERA', "Aguardando Aprovação"),
>          ('REJEITADO', "Rejeitado"),
>         ('SPAM', "Spam"),
>         )
>
> status = models.SlugField(choices=STATUS, default='ESPERA', null=True,
> blank=True)
>
> This status field should only be defined by teh admin of my System. So, It's
> not rendered
> in the public model view, using the create_object generic view. I was hoping
> that the default
> value would be used, but the model is saved with STATUS=None. Is there a way
> to enforce
> a default value to this field?
>
> thanks
>
> --
> Miguel Galves - Engenheiro de Computação

You could override your model's save method:

def save(self, **kwargs):
    if not self.status:
        self.status = 'ESPERA'
    super(YourModel, self).save(**kwargs)

Jonathan.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to