2

As the title implies, is there a way to pass url parameters to a Django wizard?

For example, in a normal view you can use the *some_parameter* value of the urlpattern:

r'^blah/(?P<some_parameter>\d{8})/$

Is it possible to do the same when there is a wizard at the specified address? Perhaps add it to the initial data dictionary for each form?

4

2 回答 2

1

If this view is based on regular Django class-based views it should take any URL arguments you pass to it, and make it accessible to its methods under self.args and self.kwargs.

See example for ListView in Django docs. In your case you'd see the argument in self.kwargs['some_parameter'].

于 2012-05-28T09:30:27.230 回答
0

Many of the generic class based views offer this functionality probably the most extensible one to capture any value that you could use would be TemplateView(). Sub-class TemplateView() and it will give you access to a context object name called params. It will be populated with variables from the url that invokes TemplateView() which it parses any variable parameters you give it.

The above answer is the most correct answer for a single model based list.

于 2012-05-28T12:30:42.917 回答