On Dec 30, 11:40 pm, schwim <gsch...@gmail.com> wrote:
> I'm trying to build a model that will store the counts of each of 10
> possible choices, e.g.:
>
>     v1 = models.IntegerField(default=0)
>     v2 = models.IntegerField(default=0)
>     v3 = models.IntegerField(default=0)
>     ...
>     v10 = models.IntegerField(default=0)
>
> I'd prefer to represent this as an array rather than 10 separate
> fields.  I looked at the CommaSeparatedIntegerField as an alternative,
> but I want to explicitly state that there are 10 entries available per
> instance.
>
> Any suggestions on how this can be done, or perhaps a better way to
> solve this puzzle?

I have a snippet here:
http://www.djangosnippets.org/snippets/1200/
which defines a custom model field and accompanying form field to
store a list of values. It doesn't currently have an option to set a
maximum number of items in the model field, just in the form field,
but that could probably be added fairly easily.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
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