On 2/8/06, Chetan Vaity <[EMAIL PROTECTED]> wrote:

class MyModel(meta.Model):
    id = meta.AutoField(primary_key = True)
    name = meta.CharField(maxlength=20, unique=True)
    location = meta.CharField(maxlength=100, choices=getLocationChoices())

What I notice is that whenever an entry is added to LDAP, it is not reflected in the SelectField drop-down on the create form for the model. But if I simply restart the Apache httpd server, the drop-down is correctly populated.

Can someone tell me why this is so?

This is so because getLocationChoices() is calculated when model is being created. To solve your problem you can do the following:

manipulator = mymodels.AddManipulator() # or ChangeManipulator
manipulator.fields[2].choices = getLocationChoices() # using 2 here is flaky, but
# we dont have any other workaround other than looping our the fields tuple and
# finding the one we are looking for.
in the view where you are using it.
 
--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701

Reply via email to