Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: prefix template blocks with two_factor_ #241

Open
danielquinn opened this issue Jan 4, 2018 · 1 comment
Open

Request: prefix template blocks with two_factor_ #241

danielquinn opened this issue Jan 4, 2018 · 1 comment

Comments

@danielquinn
Copy link
Contributor

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
@Bouke Bouke removed the enhancement label Feb 22, 2018
@vkurup
Copy link

vkurup commented Jul 16, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants