views:

34

answers:

1

Lets say i have a model A. Then, i have several models B, C, D, E etc that each have a foreignKey to model A. I know that i can set B, C, D etc as inlines to model A so that when i create a model A it will show formsets for adding multiple items for each subModel, but i think this would make a fairly cluttered and very large page.

Is there a way to somehow, instead of having all of these formsets inline on the same page, to have each formset on a separate page? in other words, there would be links from model A to create/edit associate model B's, create/edit associated model C's, etc?

Thanks!

A: 

The trivial answer would be to create a file:

${TEMPLATE_DIR}/admin/app/modelA/change_form.html

Inside your change form, you do this:

{% extends "admin/change_form.html" %}
{% block after_related_objects %}
<ul>
   <li><a href="/admin/app/modelB/{{ original.modelB.id }}/">Edit modelB</a></li>
</ul>
{% endblock %}

It's kinda primitive, but it does what you want. Lists and complex aggregations are trickier, and you'd want to test for original's presence to make sure you don't generate template errors.

Elf Sternberg