On Aug 10, 10:13 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Mon, 2009-08-10 at 19:07 -0700, Chris Curvey wrote:
> > What I want to do is have a series of forms, all next to each other in
> > table format, like this:
>
> > Car     Honda      Toyota       Chevy
> > Price   $12,000    $14,000   $10,000
> > MPG   30             28            26
> > Color  Blue          Red           Yellow
>
> > (I'm sure that's going to look like crap in a proportional font.)  But
> > the point is that Car, Price, MPG and Color are all labels, and
> > everything else (Honda, $12,000, 30, Blue, etc) is a form field.
>
> > I can create the formset and use as_table() to get the forms
> > generated, but I seem to either get the label repeated for every form,
> > or not at all.  Can someone point me in a direction to get the form
> > labels listed only once?
>
> At some point, when you're doing highly customised form layout, you have
> to switch from using the convenience methods for the simple cases and
> attend to all the little details yourself. This means laying out each
> form element appropriately. Maybe you write a template tag to do that,
> or maybe you can do it with some for-loops in the form. But as_table()
> and friends aren't designed for this kind of thing.
>

Thanks Malcolm.  Not the answer I was hoping for, but good to know
that I'm not missing something obvious.

So, is there a way for me to get a form field out of a form from
within the templating language?  I'd like to do something like this:

{% for field_name in field_names %}
<tr>
  <td>{{ field_name }}</td>
  {% for form in formset %}
  <td>{{ form[field_name] %} </td>
  {% endfor %}
</tr>
{% endfor %}

But this does not work -- Django chokes at the opening "[" with a
syntax error.

My other thought would be that I could try to add something to my
formset (a method called as_grid()) that could do the iteration in
Python and return what I need...but I could use a pointer on how to
get started with that.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to