I'm trying to replicate the inlines in the Django admin for adding related models on a FKd model on my own non admin ModelForm. In particular, when you use a StackeAdminInline and you get the "+ Add another XXX" bit of Javascript to add more of the related model.

It must be possible if the admin can do it, but I can't find a project with an example of how to do this. Can anyone point me at something? Am using Crispy Forms, although happy not to if need be. I did see https://github.com/runekaagaard/django-crispy-forms-fancy-formsets but seems as though this wasn't preferred by the Crispy maintainers, and was thinking there must be some more Djangoic way of doing this if the admin can do it already.

Thanks!

有帮助吗?

解决方案

The JS used by the admin is based on this jQuery plugin http://code.google.com/p/django-dynamic-formset/ which is still reasonably maintained.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top