WTForm should be inbuilt to Django, and make admin & others use it.

176 views
Skip to first unread message

Jari Pennanen

unread,
Mar 18, 2009, 8:06:43 PM3/18/09
to Django developers
WTForm is simple implementation built on top of existing (new)forms to
help create fieldsets, and by judging django snippets alone one can
see it's a huge hole in Django. Everyone has wondered why the heck
doing those fieldsets is such a pain when in admin it is super easy,
and it turns out the Django admin's way is unusable in elsewhere.
Thats the way I ended up doing my own fieldset implementation long ago
to ds, but as usual it went unmaintained.

When I had lost all will to Django ever implementing this, someone had
redone something similar, WTForm http://www.djangosnippets.org/snippets/214/
(unmaintained) with more care on details. Though it also went
unmaintained until akaihola took it to his care:

WTForm *Maintained* by akaihola found here http://github.com/akaihola/django-wtform/tree/master
works with Django 1.0 supposedly.

The maintained version could be added to Django, and start refactoring
parts of Django to make use of it. I mean Django admin should
definitely use this WTForm somehow, it is way more DRY than the one in
place now for the Fieldsets.

I wish people has some thoughts about this...

Joe Tyson

unread,
Mar 18, 2009, 8:11:48 PM3/18/09
to Django developers
I really hate to be a pessimist, but if the functionality already
exists for that much generation, why bother integrating it with the
main django package?

On Mar 18, 8:06 pm, Jari Pennanen <jari.penna...@gmail.com> wrote:
> WTForm is simple implementation built on top of existing (new)forms to
> help create fieldsets, and by judging django snippets alone one can
> see it's a huge hole in Django. Everyone has wondered why the heck
> doing those fieldsets is such a pain when in admin it is super easy,
> and it turns out the Django admin's way is unusable in elsewhere.
> Thats the way I ended up doing my own fieldset implementation long ago
> to ds, but as usual it went unmaintained.
>
> When I had lost all will to Django ever implementing this, someone had
> redone something similar, WTFormhttp://www.djangosnippets.org/snippets/214/
> (unmaintained) with more care on details. Though it also went
> unmaintained until akaihola took it to his care:
>
> WTForm *Maintained* by akaihola found herehttp://github.com/akaihola/django-wtform/tree/master

Malcolm Tredinnick

unread,
Mar 18, 2009, 8:24:39 PM3/18/09
to django-d...@googlegroups.com
On Wed, 2009-03-18 at 17:06 -0700, Jari Pennanen wrote:
[...]

> I wish people has some thoughts about this...

Well, one thought is that your timing is a little off. We're in the
final phases of getting the 1.1-beta release out and then it's heads
down, fixing bugs for 1.1-final.

In a couple of months or so we'll be having a discussion for proposals
to include in Django 1.2. That would be an excellent time for somebody
to bring this up -- and it probably should be akaihola, since we don't
want to conscript projects into the tree unwilling.

Having just had a quick read fo the source -- this is the first time
I've heard of the project -- it looks well enough written. Akaihola does
know his stuff; we already know that. Possibly we wouldn't pull in the
whole project, but get a patch to add the fieldsets capabilities.

I suspect, though, that adding fieldsets to forms isn't hard at all. We
just need a decent API proposed and a short patch to implement it. The
work in WTForms looks like an approach at creating one such API (since
there are neither docs nor tests, I'm reverse-engineering the API from
the code in my head, but it looks pretty decent). So the real discussion
is probably about an API.

When/if that happens, of course we'll use it internally in Django where
appropriate.

Regards,
Malcolm


Eric Florenzano

unread,
Mar 18, 2009, 8:38:45 PM3/18/09
to Django developers
If anyone else read this and was as confused as I was at first, make
sure to note that this is different than WTForms[1], which is an
alternate form library that took several of its cues from Django's
newforms.

[1] http://wtforms.simplecodes.com/

Thanks,
Eric Florenzano

sime

unread,
Mar 19, 2009, 5:38:49 PM3/19/09
to Django developers
Definite +1. The lack of fieldsets has tripped me up plenty of times.

akaihola

unread,
Mar 22, 2009, 5:47:33 AM3/22/09
to Django developers
On 19 maalis, 02:24, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> Having just had a quick read fo the source -- this is the first time
> I've heard of the project -- it looks well enough written. Akaihola does
> know his stuff; we already know that. Possibly we wouldn't pull in the
> whole project, but get a patch to add the fieldsets capabilities.

It's not my original code. I pulled Christian Joergensen's project
from pypi into my GitHub account so I could update and use it with
Django 1.0. I've now made that more clear in the GitHub description.

My only contributions so far are fixing the newforms import and
importing past releases into a git repository.

After playing with WTForm a bit it became clear that it wasn't
flexible enough for the task at hand at that time, so I created all
HTML manually instead in that project. As I'm not using WTForm in any
of my projects, I don't currently have an incentive to maintain
WTForm.

All this said, I agree that fieldsets would be an appropriate addition
to the forms library. See also ticket #8272: http://code.djangoproject.com/ticket/8272

I'll try to pull Christian into this discussion as well.

Christian Joergensen

unread,
Mar 22, 2009, 8:43:17 AM3/22/09
to django-d...@googlegroups.com
Hello,

akaihola wrote:
>> Having just had a quick read fo the source -- this is the first time
>> I've heard of the project -- it looks well enough written. Akaihola does
>> know his stuff; we already know that. Possibly we wouldn't pull in the
>> whole project, but get a patch to add the fieldsets capabilities.
>
> It's not my original code. I pulled Christian Joergensen's project
> from pypi into my GitHub account so I could update and use it with
> Django 1.0. I've now made that more clear in the GitHub description.
>
> My only contributions so far are fixing the newforms import and
> importing past releases into a git repository.

First of all; great work taking the initiative of updating WTForm to
Django 1.0.

> After playing with WTForm a bit it became clear that it wasn't
> flexible enough for the task at hand at that time, so I created all
> HTML manually instead in that project. As I'm not using WTForm in any
> of my projects, I don't currently have an incentive to maintain
> WTForm.

That's kind of the point where I arrived at too.

> All this said, I agree that fieldsets would be an appropriate addition
> to the forms library. See also ticket #8272: http://code.djangoproject.com/ticket/8272

Other than fieldsets I really believe adding CSS class attributes to the
parent HTML markup (<tr>, <p> or <li> that is, depending on the
rendering) containing the field type, the widget and a required flag
would ease the work of web designers a lot. I know it has helped our web
designer a lot.

http://www.technobabble.dk/2008/oct/09/hacking-django-forms-css-flexibility/

> I'll try to pull Christian into this discussion as well.

You succeeded :)

Regards,

Christian

--
Christian Joergensen
http://www.technobabble.dk

Andre Terra

unread,
Jun 20, 2011, 1:13:44 PM6/20/11
to django-d...@googlegroups.com
Have we moved forward with this issue at all? What is its current status?

Thank you in advance.



Sincerely,

André Terra

Carl Meyer

unread,
Jun 20, 2011, 2:11:15 PM6/20/11
to Django developers
On Jun 20, 12:13 pm, Andre Terra <andrete...@gmail.com> wrote:
> Have we moved forward with this issue at all? What is its current status?

I also maintain an external package that implements fieldsets (django-
form-utils [1]). Both django-form-utils and WTForm take the approach
of adding a Python data structure to Form.Meta that represents the
fieldsets. At one point I had thought I would push a patch to get a
fieldsets API like this into django.forms, but I'm no longer convinced
that's a good plan.

For the admin, representing fieldsets in a Python data structure in
the ModelAdmin is necessary and appropriate, since the admin is auto-
generating form rendering for a wide variety of Python models, and a
Python programmer should be able to generate these fieldsets by
touching only Python code. That's a special case. In general,
rendering of forms with fieldsets is a purely presentational issue
(the fieldsets don't impact the data submitted by the form), so I
think having fieldsets represented in Python code is the wrong
approach (and will inevitably lack the flexibility the designer needs
in their markup, just like the current hardcoded form field rendering
does). A template author and designer should be able to make changes
to the markup presentation of a form, including fieldsets, without
needing to touch Python code at all.

Gregor Müllegger is currently working on a Google Summer of Code
project to provide a templates-based flexible form rendering system. I
think this system will be flexible enough to allow template authors to
use fieldsets with forms easily and non-repetitively.

Carl

[1] http://pypi.python.org/pypi/django-form-utils
Reply all
Reply to author
Forward
0 new messages