Hi actually i did not go as smoothly as i expected :( first ModelChoiceField is *really* implemented only on development version (i was on the lastest release) so i had to clean a lot of code plus to obtain the first item on the list of choices (and not the empty string) you need to set the the empty_label key as None
but now it works! ./ed On Jun 15, 5:16 pm, "./ed" <[EMAIL PROTECTED]> wrote: > Thanks a lot! > i had the feeling it was a class/instance issue > it should work fine now > > Thx again > > ./ed > > On Jun 15, 4:53 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On Sun, Jun 15, 2008 at 7:58 AM, ./ed <[EMAIL PROTECTED]> wrote: > > > the problem is that when i add an entry to the aModel table it does > > > not update in the form (even with various reload scheme) > > > it does update when I 'touch' the python file. So my guess is the > > > problem lies in the 'compilation' chain or something like that. > > > Consider the following normal Python class: > > > import datetime > > > class BeforeAfterNoon(object): > > time = datetime.datetime.now() > > > @classmethod > > def before_noon(cls): > > return cls.time.hour < 12 > > > Now, suppose you import this class at 11:59, and call the > > 'before_noon()' method. It will return True. > > > Suppose you leave the Python interpreter running and don't reload > > anything; at 12:01, 'before_noon()' will still return True. > > > This is because -- when Python parsed the class definition -- the > > current date and time were assigned to the attribute 'time' in the > > class, the same as if a constant value had been assigned, and it won't > > change until something forces the class definition to be completely > > reloaded, at which point it will update to a new value and stick > > *there* instead. > > > Assigning choices to a field in a form works the same way; even if the > > choices come from calling a function, it still happens only once -- > > when the class is first loaded. > > > This deals with the general case of what you're seeing. For the > > specific case of dynamically pulling choices for a form field from a > > QuerySet, you want to take a look at the documentation: > > >http://www.djangoproject.com/documentation/newforms/#fields-which-han... > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---