Crispy_forms_tag’ is not a valid tag library

djangodjango-crispy-forms

I'm trying to create a Django app using Django crispy-forms.

settings.py

CRISPY_TEMPLATE_PACK = 'bootstrap3'

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'face',    #app name
    'crispy_forms',
)

index.html

{% extends "base.html" %}
{% load crispy_forms_tag %}

{% block title %}
AuthorizedUser
{% endblock title %}

{% block content %}
    <h1>Quote of the Day</h1>
    <blockquote>{{quote}}</blockquote>
    <p>Or, hit reload if you want a new one...</p>

    <form method="POST" action="{% url  %}"  >
        {% csrf_token %}
        {{ form|crispy}}
        <input type="hidden" name="quote" value="{{quote}}" />
        <input type="hidden" name="access_token" value="{{access_token}}" />
        <input type="submit" value="Set as my status!"/>
    </form>
{% endblock content %}

When I'm running server it's raising an error

"TemplateSyntaxError at / 'crispy_forms_tag' is not a valid tag library: Template library crispy_forms_tag not found, trieddjango.templatetags.crispy_forms_tag,django.contrib.staticfiles.templatetags.crispy_forms_tag,django_facebook.templatetags.crispy_forms_tag,crispy_forms.templatetags.crispy_forms_tag".

What am I doing wrong? And how to fix it?

Best Solution

You should add Crispy Form tag in project setting .

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'crispy_forms',
]

add these crisp tag in your templates.html

    {% load crispy_forms_tags %}
      {% csrf_token %}
    {% crispy form %}
Related Question