问题
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