Django Admin like Inlines in my ModelForm
Asked Answered
H

1

6

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!

Hibachi answered 24/5, 2012 at 15:27 Comment(0)
P
4

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.

Pineapple answered 24/5, 2012 at 15:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.