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