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?
I've gone through that error just now.
Forgot to install django-crispy-forms
pip install django-crispy-forms
and refer it in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
]
Once that was done, the problem was solved.
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 %}
Are you sure that the installation of Crispy forms worked ? you need to install django-crispy-forms.
Then, in your template index.html, you should use the crispy tag as following :
{% crispy name_form %}
instead of :
{{form|crispy}}
What's more, you should use
{% load crispy_forms_tags %}
not,
{% load crispy_forms_tag %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With