django-two-factor-auth
django-two-factor-auth copied to clipboard
Request: prefix template blocks with two_factor_
As it's commonplace for projects to use the name content
for blocks within the project, two_factor's use of the same generic name makes it difficult to override _base.html
for style without effectively having to override everything.
Expected Behaviour
Ideally, one should be able to create a my_app/two_factor/_base.html
with contents like the following:
{% extends 'my-base.html' %}
{% block content %}
<h1>2fa Stuffs</1>
<div class="some-formatting-class">
{% block two_factor_content %}{% endblock %}
</div>
{% endblock %}
Current Behavior
Django doesn't like it when you nest blocks:
'block' tag with name 'content' appears more than once
Possible Solution
Rename all references from {% block content %}
to {% block two_factor_content %}
.
Context
I'm looking at writing a hackish template tag that sort of side-loads the template and writes the output so I can do this:
{% extends 'my-base.html' %}
{% block content %}
<h1>2fa Stuffs</1>
<div class="some-formatting-class">
{% two_factor_hack 'login.html' %}
</div>
{% endblock %}
Not ideal, but I'd rather do this than copy/paste this project's templates into mine and hope to keep them in sync between updates.
Your Environment
- Python version: 3.6
- Django version: 1.11
- django-otp version: 0.4.2
- django-two-factor-auth version: 1.7.0
This would be a useful change for me as well.
I currently have a account/base.html
template that provides some common markup for all of my account pages. My individual account pages put their distinct content into an account_content
block, and then the account/base.html
templates put all of the account_content
content into a content
block which is then put into my main site base.html
template.
Since the two_factor
app uses the block name content
, that nice hierarchical separation is bypassed and the two_factor
content goes directly into my main site's base.html
template without the proper common account_content
markup surrounding it.