On Sunday, March 11, 2012 at 12:43 PM, shacker wrote: > On Sunday, March 11, 2012 6:24:30 AM UTC-7, skhohlov wrote: > > Of course form does not have access to the object. > > > skholov - Thanks, but you misunderstand my question. Again, I know that forms > don't have access to request, and again, I've got it working already (though > with a different approach - see my OP). My question was an attempt to > understand the plumbing or the python better. To reiterate, I'd like to know > WHY request isn't automatically available from forms, as it is from views. To > put the question another way, when we define a view function, we do something > like: > > def edit(request,story_id): > ... This is a function that get's passed request as it's first argument. Since view functions are _always_ run during the request response cycle of an HTTP request, request is always available to be passed into the view. > > But when we create a form, we can't just do: > > class StoryForm(ModelForm, request): > ... > >
This is subclassing the form from request. the equivalent code would be to accept the request in the forms __init__, however this would need to be option to still allow using the forms outside of the request, response cycle. This parameter is very easy to add on your own and including it by default needlessly ties the form processing library to django requests. > > It seems like this is the kind of thing Django could take care of for us - we > shouldn't have to jump through hoops to get at request - but there's > probably a good reason why it works this way. Does my question make more > sense now? > > Thanks, > Scot > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/8DXqXSX-YhAJ. > To post to this group, send email to [email protected] > (mailto:[email protected]). > To unsubscribe from this group, send email to > [email protected] > (mailto:[email protected]). > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. 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.

