【发布时间】:2014-07-28 08:48:51
【问题描述】:
我正在尝试使用 Django crispy-forms 创建一个 Django 应用程序。
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 %}
当我运行服务器时,它会引发错误
“
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”。
我做错了什么?以及如何解决?
【问题讨论】:
-
为什么不使用 django 表单?在那里你应该定义一个助手..
标签: django django-crispy-forms