I have read quickly the article "Variable Choice Lists'. I don't have
a lot experience with Django, however I would try to explain my case.
I have  a model in which one of the fields has to be 'SelectedField',
therefore I have to use a 'choices' options.

class Dataset(models.Model):
   .....
   .....
   choice = models.IntegerField(choices=LT)
   .....

The choice field in this model has to get information from other model
in other application, but in the same project. What I have done is
this:

   from project.app.models import Model

   all_entries = Model.objects.all()
   ls = []
   LT = []
   for elm in all_entires:
       ls.append(int(elm.attr))

   for elm in ls:
      (f,s) =(i,elm)
      LT.append((f, '%s' % s))

So this manner I try to get information for this Field. I don't know
whether it is a correct manner.
Besides I would like to say that on 'pointy-stick.com' site are very
interesting articles about different subject.

Regards,
Nader





On Nov 20, 10:47 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2007-11-20 at 00:19 -0800,Naderwrote:
> > Hallo,
>
> > I have a model in which I have to use a input-field withchoices
> > option.
>
> > ACCESS = (
> >      ('RO', 'readonly'),
> >      ('WO', 'writeonly'),
> >      ('RW', 'readwrite'),
> >      )
>
> > Class myClass (...)
> >    ..
> >    ...
> >    active = models.IntegerField(choices=ACCESS, radio_admin=True)
> >    ...
>
> > The value for 'choices' is of tuple type, actually tuple of tuple. In
> > some case I have to use some dynamic information, it means that I
> > don't know in front how many element in tuple will be present. I can
> > define a empty tuple and then assign the elements to the tuple, but
> > tuple is a unmutuable type. I can't use also 'list' or dictionary.
> > Would you like to help me to solve this problem.
>
> If you mean that every single time you access the field thechoices
> might be different, then you don't want to be using 'choices' here. You
> want a many-to-many field instead. If you mean that you won't know the
> value ofchoicesuntil the *first* time you access the field, read this:
>
> http://www.pointy-stick.com/blog/2007/03/26/django-tips-variable-choi...
>
> Regards,
> Malcolm
>
> --
> He who laughs last thinks slowest.http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
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