Give customized Context to own templates for predefined Django Reset Password Classes
I am relatively new do django. I try to test my abilities by slightly altering a simple social media app, I learned at a course. In my app I always want to see the index page with the posts and the navbar, etc... And everything user related like login, logout, register, change password or edit profile should be shown as a popover over the index page. This works fine with all the above. For that I render those templates and they extend the index page (which in return extends the base.html...) For that I give those renders (login, logout, etc...) their own context but also the context needed to correctly render the index page, namely the complete post objects. (I am sure, there is a better way to achieve this goal, but before I learn that, I want to walk this path ones. And so far it works fine.)
My question now is this: For the password reset routine I use the Django provided classes PasswordResetView, etc. And yes, in the urls.py I can give them custom templates with "template_name=". But to show them as popovers, I need to give them the index context as well and I don't know, how to do that. Is there a way to extend them to accept custom context as well or is the capability already baked into them somehow? I wasn't able to find a solution.
To add custom context to Django's built-in password reset views, use the extra_context attribute or override get_context_data
It works:
I tried it like that:
path('password_reset/',auth_views.PasswordResetView.as_view(extra_context={'blib':'BLIB BITCH'},template_name='users/pw_reset_form.html'), name="password_reset")
and the template can see it!!! YES!!! Thx!