Sorry-- I got out of sync with the replies.
> Or am I missing something. Â Seems like I am getting very much NON-DRY here.
How many pages do you have dozens of forms on? If ever, I find that
I've got a single form on the page. If you're writing an app complex
enough to need such amazingly complicated nested forms.... should you
use the admin, and let it do all that for you?
We're not really working with specifics here, so I'm unsure of what
you're trying to accomplish.
How would you propose we get around this problem? You've got a python
list of form objects. How on earth is Django supposed to know what
variable you've got your forms in? By forcing you to put all your
forms in a single variable, it would make Django dictate too strongly
"the one and only variable which can hold forms". That exactly what
it's trying not to do.
Just set up a template, perhaps "base.html". Make it something like
this:
<html>
<head>
<title>blah</title>
{% block my_media %}
{{ media }}
{% endblock %}
</head>
<body>
{% content %}{% endcontent %}
</body>
</html>
Then, in your views, you'll render the actual template you want to use
(as in, don't render "base.html", render the one that you'd normally
render), but make sure it extends base:
{# mytemplate.html #}
{% extends "base.html" %}
{% block content %}
my content goes here...
<form>
{% for form in forms %}
{{ form.as_p }}
{% endfor %}
</form>
{% endblock %}
The idea is that the 'base.html' template will *always* try to grab
the context variable "media" and render it. That means that all you
ever have to do is make sure that the context variable "media"
contains the cumulative media of what you want to include. Note,
though, that when you want to use this "extends" approach, you become
required to work in those blocks. that's why I put a "content" block
in the base template, and override it in the extended one. Stuff
outside of blocks in mytemplate.html won't get displayed. This is a
very common approach, though, so don't feel like you're getting
cheated.
Then, if you ever want to for whatever reason add more media beyond
the form media, you can either slap it into the 'media' context var in
your view, or you can do that block override I kept using the first
examples:
{# mytemplate.html #}
{% block my_media %}
{{ block.super }}
<script type="text/javascript" src="blahblah/my.js" />
{% endblock %}
{% block content %}
{# continue as usual #}
{% endblock %}
I hope I'm not spouting nonsense that you are already familiar with.
Feel free to ask anything more, if you've got specifics that you're
trying to nail down, design-wise.
Tim