Django crispy-forms cannot find CSS

只愿长相守 提交于 2019-12-22 11:01:21

问题


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?


回答1:


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?



来源:https://stackoverflow.com/questions/14683614/django-crispy-forms-cannot-find-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!