Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Admin like Inlines in my ModelForm

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!

like image 253
Ludo Avatar asked May 24 '12 15:05

Ludo


1 Answers

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.

like image 123
Mark Lavin Avatar answered Oct 20 '22 01:10

Mark Lavin