I have reimplemented my project to use django.newforms. At all, I
conclude that newforms saved some of my time and its a good tool
already.
But since its a alpha only I had a few troubles and few things which I
think are good to change.
1. At first, I already mailed this mailing list about the Error design
in this thread:
http://groups.google.com.ua/group/django-developers/browse_frm/thread/9ad73e39d876e394
2. Sometimes its very important for me to show some initial values in
form, on 'Add' screen. Typical
example, is a form, where customer can specify a different First,Last
Name and Email address. If
I pass data=xxx to form constructor, it will perform validation, and
since all other fields are empty,
this will bring a error.
3. Sometimes, its very important to specify field names. I was not able
to change it. For example, to save
using django own manipulator, I had to rename field before saving:
data['customizedaddress.0.subject'] =
data['subject_taught']
For a different reasons, there must be a way to override and specify
own field name. May be I should try to pass it via attrs to widget?
4. In documentation its said: "django.newforms is a new replacement for
django.forms, the old Django form/manipulator/validation framework.".
The question is, if it replaces manipulators, where is this part? Is
not developed yet? Because I've still used manupulators to save data.
Otherwise my code will grow 2-3 times by passing completely similar
arrays of model data for save/add/change.
Just as example of my code, using django.newforms is here:
http://dpaste.com/4044/
Regards,
Alex
This is a good point -- I was going to suggest just passing the
default values as data to the form, but that would indeed cause the
other fields to be validated. Any ideas on a solution to this? We
could add a "default" parameter to a Field, as has been discussed
before, but something about that rubs me the wrong way.
> 3. Sometimes, its very important to specify field names. I was not able
> to change it. For example, to save
> using django own manipulator, I had to rename field before saving:
> data['customizedaddress.0.subject'] =
> data['subject_taught']
> For a different reasons, there must be a way to override and specify
> own field name. May be I should try to pass it via attrs to widget?
I'm not sure I understand your question here; are you saying you'd
like to rename the fields used in a Form generated by
form_for_model()?
> 4. In documentation its said: "django.newforms is a new replacement for
> django.forms, the old Django form/manipulator/validation framework.".
> The question is, if it replaces manipulators, where is this part? Is
> not developed yet? Because I've still used manupulators to save data.
> Otherwise my code will grow 2-3 times by passing completely similar
> arrays of model data for save/add/change.
I've started the implementation for this -- it's the function
django.newforms.form_for_model(). It's not finished yet, though.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
there could be an initial_value parameter for Fields... I have
implemented it as part of the default parameter, I am still waiting
for any feedback, one of the solutions to that problem (see the post
in this group [0]) would be to split the behaviour between
initial_value -- something to display in a field when created
and
default -- something to replace empty value when submitted
0 -- http://groups-beta.google.com/group/django-developers/msg/82d8f4299afc2af0
>
> > 3. Sometimes, its very important to specify field names. I was not able
> > to change it. For example, to save
> > using django own manipulator, I had to rename field before saving:
> > data['customizedaddress.0.subject'] =
> > data['subject_taught']
> > For a different reasons, there must be a way to override and specify
> > own field name. May be I should try to pass it via attrs to widget?
>
> I'm not sure I understand your question here; are you saying you'd
> like to rename the fields used in a Form generated by
> form_for_model()?
>
> > 4. In documentation its said: "django.newforms is a new replacement for
> > django.forms, the old Django form/manipulator/validation framework.".
> > The question is, if it replaces manipulators, where is this part? Is
> > not developed yet? Because I've still used manupulators to save data.
> > Otherwise my code will grow 2-3 times by passing completely similar
> > arrays of model data for save/add/change.
>
> I've started the implementation for this -- it's the function
> django.newforms.form_for_model(). It's not finished yet, though.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com
>
> >
>
--
Honza Král
E-Mail: Honza...@gmail.com
ICQ#: 107471613
Phone: +420 606 678585
Giving feedback for that is on my to-do list as I read through several
hundred Google Groups messages...Thanks for your patience so far!
no problem, I was hoping to get some feedback from other people - I
know you have quite a few things to do just on django, so I didn't
even expect your direct input, I thought that some potential user
would say something...
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com
>
> >
>
I'd like a dict to hold the default values, so we can get then from a
instance or somewhere easily, but not set each field a default value.
for example, the new forms __init__.py can has a defaultvalues
parameter is a dict. When it will be rendered, it'll check the data,
if the data is None, so it'll use defaultdata.
--
I like python!
UliPad <<The Python Editor>>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou
I like this idea a lot. Perhaps 'default_data'.
As of changeset [4249], I've implemented an "initial" parameter for
Fields, which lets you specify something to display when the Field is
in a Form that hasn't received any data (i.e., a Form that has been
initialized with data=None).