On Thu, 2009-01-08 at 17:32 -0800, adrian wrote:
> 
> Is there a way to display a form with fields grouped using fieldsets,
> without entering all the html manually in the view?   The Form I have
> in mind is generated directly from a Model.   I see that the admin has
> this feature but it isn't mentioned anywhere else in the doc.

The way admin does it is somewhat specific to the admin. But if
something in Django already does what you want, that's a clue: look at
how Django does it. Change into the django/contrib/admin/ directory and
search for the word "fieldset". You'll see references to InlineAdminForm
and might be able to write an equivalent of something like that for
yourself.

> This would have two advantages - one it's an easy way to control
> display of fields in the view without loads of manual html.   Since I
> have choices for some of my fields, the manual html is large and
> clutters up my view.
> 
> Second it would let me reorder the fields in the view with affecting
> the model.   Once a database is live it's not so easy to change it but
> I'd still like the freedom to change the view it's based on (without
> voluminous html).

Django's form classes are designed to be subclassed and extended and we
intentionally don't try to do more than provide the basic foundation, as
there are far too many possibilities to try and cover the field (it
would also be seen as too generally restrictive). So do that. Write some
Python code that does what you want. Use InlineAdminForm as inspiration.

If your code turns out to be wonderfully useful, stick it up on Google
code or somewhere as a useful library that others might want to use. Or
not.

I'm really not trying to be dismissive here. This is an expectation
thing. In many cases, you are expected to build on top of what Django
provides. Certainly have a look and ask, as you're doing, to see if the
code already exists in Django. However, don't be afraid or shocked when
it requires building on top of the existing libraries (again, not
assuming you will have that reaction, but it seems to be a common enough
response).

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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