Django crispy-forms找不到CSS [英] Django crispy-forms cannot find CSS
问题描述
我添加了
CRISPY_TEMPLATE_PACK ='bootstrap'
到我的 settings.py
文件。
html文件很简单:
{%extends'base.html'%}
{%load crispy_forms_tags%}
{%block content%}
{%crispy form%}
{%endblock%}
还有什么需要使其工作?据了解,由于引导文件与crispy_forms捆绑在一起,因此我不需要在项目的CSS路径中复制并引用它们。这是正确的吗?
听起来好像你的django实例找不到 static
文件为脆性表单。如果您正在运行开发服务器,请在
INSTALLED_APPS
中包含'crispy_forms'
?
如果您正在运行生产服务器,您可能需要确保您的 STATIC_FILES
路径正确,您运行 collectstatic
最近。
作者记录了安装过程这里 - 你完全遵循了吗?
I am using Django and Crispy Forms. I can get the form to render correctly, but no CSS formatting appears. What do I need to do?
I have added
CRISPY_TEMPLATE_PACK = 'bootstrap'
to my settings.py
file.
The html file is as simple as it gets:
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% block content %}
{% crispy form %}
{% endblock %}
What else is necessary to make it work? I understand that since the bootstrap files come bundled with crispy_forms, I don't need to copy and reference them specifically in my project's CSS path. Is this correct?
It sounds as if your django instance can't find the static
files for crispy forms. If you are running the development server, have you included 'crispy_forms'
in INSTALLED_APPS
?
If you're running a production server you'll probably need to ensure that your STATIC_FILES
paths are correct and you've run collectstatic
recently.
The authors have documented the installation process here - have you followed that completely?
这篇关于Django crispy-forms找不到CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!