Maybe redundant isn't the right word. It can be done with the code
provided by newforms so that you don't need to define things inside
your views like that. Let the form handle all of the form handling and
your view handle the processing of the request to the form and then
how to respond to the request. I find that is the best way to create
newforms.

Also be careful. I think I see a bit of old forms creeping into you
code. Don't let old blog posts trick you into using old code.

Good Luck,

Michael

On Tue, Apr 1, 2008 at 11:04 AM, oliver <[EMAIL PROTECTED]> wrote:
>
>  ok, still have to learn more (i thought i was getting to grips with
>  newforms). Every time i figure something out it reduce the code I have
>  writen before.
>
>  The complexity with this project is that this is the 1st from from
>  about 6 hence why we dump it all into request session. I looked at the
>  form wizard module which looks like it could help with this.
>
>  @Michael: why are the initial values redundant? I know the validation
>  is a bit odd but over all the way i am dealing with creating the form
>  and validating and saving it is correct or? there is just "excess"
>  code which admit ably is not very usefull ;)
>
>  Thanks any way, i am plaming this one on looking at the same code for
>  way to long :(
>
>
>  On Apr 1, 3:44 pm, Michael <[EMAIL PROTECTED]> wrote:
>  > Just briefly looking at the way that you have done this, I ask why are
>  > you using new forms in the first place? All the validation that you
>  > are doing is redundant, all the calls and initial values you are
>  > trying to accomplish is redundant.
>  >
>  > Newforms (and any python to HTML forms) are a tool to help you create
>  > and handle forms between httprequests and the python. Newforms is
>  > great in that you can have a whole form and all of it's handling done
>  > in just a few lines of code. You have about 100 lines that look like
>  > they want to handle raw data. If you want to handle raw data, handle
>  > raw data. If you want to allow newforms to help you create and handle
>  > HTML forms, read the 
> documentation:http://www.djangoproject.com/documentation/newforms/
>  >
>  > What you are trying to accomplish, if you properly implement NewForms
>  > and request sessions, should be much cleaner and more simple.
>  >
>
>
> > On Tue, Apr 1, 2008 at 10:29 AM, oliver <[EMAIL PROTECTED]> wrote:
>  >
>  > >  I just found a post where they do this ..
>  > >   testform = BookingFormOne(initial={
>  > >       'u_1stline': user.get_profile().currentAddress.street1,
>  > >       }
>  > >     )
>  > >  as in call initial when the form class is called. and it seems to
>  > >  work!?!
>  >
>  > >  can any one explain why thou? as i still dont get why my way is not
>  > >  doing it right.
>  >
>  > >  On Apr 1, 3:09 pm, oliver <[EMAIL PROTECTED]> wrote:
>  > >  > Hi,
>  >
>  > >  > I have this very wired problem and I just can not figure out why it is
>  > >  > happening.
>  > >  > Newfroms seem to not send the "initial" value for a field on the 1st
>  > >  > load of the view.
>  >
>  > >  > This is the code:http://dpaste.com/42561/
>  >
>  > >  > its "just" a form
>  > >  > and a view that calls the form.
>  >
>  > >  > The problem lies with adding the initial runtime values to some of the
>  > >  > form fields. The code is from line 59 onwards.
>  >
>  > >  > What happens:
>  > >  > I load the view page for this form, and I get an empty form (again
>  > >  > this happens some times but not every time!!?), I press F5 and
>  > >  > suddenly the form has the inital data in the fields.
>  >
>  > >  > if I do a "print testform" in my view (after the data should be loaded
>  > >  > in) it prints the form in the console but I can see it is missing the
>  > >  > "Value" attribute. If i refresh it is there.
>  >
>  > >  > I dont think it is a caching issue as django it self is not sending
>  > >  > the "value" in the testform object on 1st load. but on 2nd load it
>  > >  > does.
>  >
>  > >  > I have checked with various print statements that the data is there
>  > >  > which it is!
>  > >  > I have removed the "if Post" and split the view up so I only call
>  > >  > "render a fresh form with initial data".
>  > >  > I have disabled Cache in the browser(s) (ie7,ff,safari).
>  > >  > I have disabled Cache in the view.
>  > >  > Calling the URL return html 200 code which should be correct.
>  >
>  > >  > Running the latest Django svn with the dev server (but it also happens
>  > >  > when I run it via our apache live setup).
>  >
>  > >  > Also if I get the form to load data, than log out and login as some
>  > >  > one else and go to the same form it has the Initial data of the user
>  > >  > before in it!! and I need to refresh 2 again to get the current users
>  > >  > data.
>  >
>  > >  > Once the data is in there it all works greate, validation and so on is
>  > >  > all fine.
>  >
>  > >  > I getting really frustrated with this issue and can not find any thing
>  > >  > regarding this online or in the django groups. And I just can;t see
>  > >  > where the code is wrong or why it would not load the data every time
>  > >  > view is loaded with out a post.
>  >
>  > >  > Please any comments/help will be really appreciated!
>  >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to