Passing Custom variables to password_change view in Django
I want to use the password_change view from contrib.auth.
So here is what I did:
- Created a form that extended the PasswordChangeForm to add html classes to the widget
- Created the registration/password_change.html template. Because you perform password change from a logged in state, this template must inherit from a base_site.html that displays the user a bunch of information (in addition to the form).
- Updated my urls.py to create the pattern for URL, passing in the form name to the view.
Here is where I am stumped. The template, it renders content based on some custom variables. For example, the template has a custom tag that obtains information from the context.
business = context.get('business',None)
My question is: what are my options to passing domain specific context to the template开发者_开发知识库? Should I go ahead and rewrite the password_change view (copy and paste) into my application view?
Django's generic views emply an extra_context
parameter for this purpose. However, auth provides its views as is; you don't have to use them.
Your only option is to simply recreate the view. You can copy the code from password_change
, as a guide, but make sure you understand what it's doing before you just drop it in.
精彩评论