FormPreview and template variables

4 views
Skip to first unread message

NewsNerd

unread,
Oct 27, 2011, 7:38:41 PM10/27/11
to django...@googlegroups.com
I'm a Django noob and fear the answer to my question is fairly obvious, but hoping someone can help.

I'm building an app that includes the same form on every page, with the content surrounding the form and the model instance to which the form data is tied dependent on a value passed in the URL. Works fine using the standard Form class and (URL, 'template.html', myapp.view) in URLconf, like so:

url(r'^listings/(?P<listing_id>\d+)/submit$', 'myapp.views.lister'),

With FormPreview, however, instead of calling the view in the URLconf, you're calling the subclass with the view functionality baked in.

url(r'^listings/(?P<listing_id>\d+)/submit$', PickFormPreview(PickForm)),

From what I can gather from the docs, FormPreview uses parse_params to pass values captured in the URL to state.self, which I believe is a dictionary. Unfortunately given my level of experience, I can't figure out from this barebones understanding how to customize my FormPreview subclass how to pass the listing_id captured in the URL to a template variable in my form.html template called by FormPreview. Do I somehow need to override parse_params? Or somehow pass state.listing_id? Or am I missing it entirely?

Any help much appreciated!

Reply all
Reply to author
Forward
0 new messages