开发者

django form choice field refresh

I have a choice field on a form which allows the user to select a table from within my postgres database. Using the development server this is populated during the runserver command. The problem I have is I would like the choice field to update with new tables which may be created by user. At present the only way to make new tables available in the choice field is to start and stop the开发者_StackOverflow server. Is there a way this can be done automatically?


Define a custom __init__ method on your form. Call super(MyForm, self).__init__(*args, **kwargs), and then set self.fields["thechoicefield"].choices when you initialize the form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜