Django calls your view with the request object and some_param
, which you have access to inside views.some_view
. Your function will have the following signature:
def some_view(request, some_param):
....
Or:
def some_view(request, **kwargs):
some_param=kwargs.get('some_param', None)
You can then use some_param
inside your view to do whatever you need to do with it, save it in a database, put it in a cookie, do calculations with it, get some database data with it, etc. Then once you're done, you need to return a response object. Usually by calling render
or TemplateResponse
with a template or returning HttpResponse without a template. You render templates providing a context
dictionary which you are free to put anything you like into (like some_param
), which makes it available to be rendered in your HTML template. That rendered HTML template is then returned as response to your user through the magic of the render
function or TemplateResponse
class, which ends the view process. I.e. like so:
return TemplateResponse(request, 'template.html', context)
To store some_param
in between views, you'll need to save it in the database, store it in the user's session, or use a cookie. Or pass it to the next view inside the url or outside the url via /?param=some_param. Without saying what you need some_param
for later on, it's hard to solve your issue.