I am using django-allauth
with a custom signup template based on the default. Is there a way to include custom template tags in the template? using {% load custom_tags %}
gives me a TemplateSyntaxError: custom_tags is not a registered tag library. Must be one of:
. Here is my code:
templates/account/signup.html
(overrides allauth
default)
{% extends "account/base_entrance.html" %}
{% load allauth i18n %}
{% load custom_tags %}
{% block head_title %}
{% trans "Sign Up" %}
{% endblock head_title %}
{% block content %}
{% element h1 %}
{% trans "Sign Up" %}
{% endelement %}
<p>
{% blocktrans %}Already have an account? Thsen please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}
</p>
{% url 'account_signup' as action_url %}
{% element form form=form method="post" action=action_url tags="entrance,signup" %}
{% slot body %}
{% csrf_token %}
{% element fields form=form unlabeled=True %}
{% endelement %}
{% if redirect_field_value %}
<input type="hidden"
name="{{ redirect_field_name }}"
value="{{ redirect_field_value }}" />
{% endif %}
{% endslot %}
{% slot actions %}
{% element button tags="prominent,signup" type="submit" %}
{% trans "Sign Up" %}
{% endelement %}
{% endslot %}
{% endelement %}
{% if SOCIALACCOUNT_ENABLED %}
{% include "socialaccount/snippets/login.html" with page_layout="entrance" %}
{% endif %}
{% endblock content %}
tempalatetags/custom_tags.py
from django import template
from django.http import HttpRequest
register = template.Library()
# A test tag.
@register.simple_tag(takes_context=True)
def tag(context):
return context['request']['address']