<jaroslav.dobrek@gmail.com> wrote:
>> You are confusing model fields with form fields. MultipleChoiceField
>> is a form field, not a model field.
>
> I wasn't aware of the existence of MultipleChoiceFields. The idea of
> the above code was to express that I wanted to use this code
>
> class Candidate(models.Model):
>
> programming_languages = models.CharField(max_length=50, choices=(
>
> (u'Python)', u'Python'),
> (u'C++', u'C++'),
> (u'Java', u'Java'),
> # ...
> ), blank=True)
>
> with the only exception that, in the admin interface, several choices
> are possible when one creates a new candidate object. I.e. I want
> admins to be able to create a candidate that knows, say Python *and* C+
> + by choosing both of these languages during the creation of the
> object. I used the string "MultipleChoiceField" as a dummy for
> whatever should be used instead.
>
> Jaroslav
>
That isn't possible with a single field using Django's default fields.
You want a ManyToManyField to a separate LanguageChoices model.
As an alternative, you could define a new field type that would use
MultipleChoiceField as the form field, and compresses and decompresses
from a single value. This would be a lot more work than simply
defining the additional model.
Cheers
Tom
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment