views:

40

answers:

1

I have a model that picks up the choices defined in CHOICES like this:

CHOICES = (
    ('1', '1'),
    ('2', '2'),
    ('3', '3'),
)

class select(models.Model):
  first = models.CharField(max_length=3, choices=CHOICES)
  second = models.CharField(max_length=3, choices=CHOICES)

I would like to be able to add, remove or change choices in the admin page. So my approach would be to have CHOICES as a model, but I dont know if this is the right way to do this. If it is, then how can I set it? Thanks.

+4  A: 

You want something like a ManyToMany field, not choices on a Character field. More info here: http://docs.djangoproject.com/en/1.0/ref/models/fields/#django.db.models.ManyToManyField

Bryan
Thanks! Problem solved.
Ping Pengũin
I think that ForeignKey pointing to some model is an enough solution for this case, isn't it?
Lukasz Dziedzia
Yes Lukasz, that is what I did in the end. thanks
Ping Pengũin