Wednesday, October 29, 2014

Re: pre-populate tabular inline in admin

Hello,

This one's tricky. It may be simplest to just _create_ the empty inline ModelA's so they appear. Otherwise, you'll need to look at the ModelA's that exist in the database and figure out which ones needed to be added to the initial data.

You'll likely need to add the initial data using the get_formsets_with_inlines hook.
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_formsets_with_inlines

And you can always peak at the source code to get a better feel for what's going on :)
https://github.com/django/django/blob/master/django/contrib/admin/options.py

Collin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c6863bb0-0727-4354-824e-91aad404fa68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment