Ad
How To Use Base_template Variable In Django Login.html
I have a very simple Django 3.1 project that uses the basic login-authentication found in the Mozilla tutorial (https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Authentication).
It works great, but I'd like to change the extends base_generic line to a variable.
For example, logged_out.html, currently looks like this:
{% extends "base_generic.html" %}
{% block content %}
<p>Logged out!</p>
<a href="{% url 'login'%}">Click here to login again.</a>
{% endblock %}
I'd like it to look like this:
{% extends base_template %} <-- Here's the change I'd like to make
{% block content %}
<p>Logged out!</p>
<a href="{% url 'login'%}">Click here to login again.</a>
{% endblock %}
I've been able to do this successfully for all the templates that I create, but I can't figure out how to do this for the "built-in" login-authentication pages, such as login.html, logged_out.html, password_reset_form.html, etc
Thank you!
Ad
Answer
you can define your own template and change urls.py. Example changing a template for auth_views.LogoutView:
urlpatterns = [
path('logout/',
auth_views.LogoutView.as_view(template_name='customers/logout.html'),
name='logout'),
]
Ad
source: stackoverflow.com
Related Questions
- → Django, code inside <script> tag doesn't work in a template
- → Uncaught ReferenceError: Parent is not defined
- → React - Django webpack config with dynamic 'output'
- → Put a Rendered Django Template in Json along with some other items
- → Implement shopify templates in django
- → Python Shopify API output formatted datetime string in django template
- → How to avoid being crawled/penalized by Google
- → Django: Identify the urls that provide duplicate content and set a canonical link
- → Shopify app: adding a new shipping address via webhook
- → Jquery Modal Confirmation on Django form submit for deletion of object
- → changing the size of an image with css
- → shopify_auth multi store session handling
- → How to use Shopify Python API RecurringApplicationCharge
Ad