开发者

Adding file field dynamically in django forms

I am working on an application where I have a form开发者_JAVA百科 which has some form fields along with a file field. What I want is, to have a link or button "Attach another file" and it should append a new file field on click on that link. Something similar to gmail's file attachment functionality.

Any hint on how it can be implemented?

Thanks in advance.


Use a formset which, by definition, contains arbitrary number of forms. In your case, the form contains just a file field.

Documentation: http://docs.djangoproject.com/en/dev/topics/forms/formsets/

If you edit the number of forms on the page, via javascript, which you probably want to do, note that, you need to edit the management form values.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜