2👍
You should try this instead:
{% load static %}
{% block css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.css ' %}">
{% endblock %}
…and just make sure you have ‘django.contrib.staticfiles’ in your INSTALLED_APPS
. Please see also https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#template-tags
(EDIT: fixed typo, I oroginally forgot the “static” keyword)
OR this:
{% block css %}
<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}css/bootstrap.css">
{% endblock %}
..assuming “django.core.context_processors.media” is in your TEMPLATE_CONTEXT_PROCESSORS
1👍
Take a look at the faststart-bootstrap Django project skeleton with Bootstrap 3 support. However it’s based on LESS style sheets, but LESS is easy to learn (in use) and compatible with CSS.
0👍
ok, that’s a settings and path problem.
First, put that in your settings:
PROJECT_PATH = os.path.abspath(os.path.dirname(__name__))
MEDIA_ROOT = os.join(PROJECT_PATH, 'uploads')
MEDIA_URL = '/media/'
STATIC_ROOT = os.join(PROJECT_PATH, 'static')
STATIC_URL = '/static/'
And that in your template
{% block css %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}/css/bootstrap.css">
{% endblock %}
0👍
Check your project structure. I follow this structure:
/Project_name
/App1
/App2
/App3
/Project_name
/media
/static
/css
bootstrap.min.css
/js
/templates
/Requirements
requirement.txt
.gitignore
With this structure and a proper settings and template files shown by lalo, bootstrap should be work without 404.
- [Django]-Reverse {% url %}: Reverse for '"' not found. '' is not a valid view function or pattern name
- [Django]-Is there a way to display the color of a (hex color) field in the Django Admin site?