1

I am new with django and python, have create a test project which works well until the point try to change the design like css, js and some img. I installed bootstrap as well, when I upload the three files, css, js and img, The page can not find my css file and others. On my server display this message:

[30/Jan/2014 11:19:15] "GET /static/ HTTP/1.1" 404 1614 [30/Jan/2014 11:19:34] "GET /static/css/bootstrap.css HTTP/1.1" 404 1655

I tried ti find the css page from developer section on firework which jump to this page: Page not found (404) Request Method: GET Request URL:

localhost:8000/static/css/bootstrap.css 'css/bootstrap.css' could not be found You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

And below is the link on base.html to the css files. href="/static/css/bootstrap.css"

Could you please give me an idea what is wrong here, I do appreciate?

Thanks Dilshad

1
  • It would be nice to know the folder structure of your project, at least the full path of the bootstrap.css file Commented Jan 30, 2014 at 13:16

1 Answer 1

3

if you have your css folder in static folder and you have this in your settings.py:

STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
'/var/www/static/',
)

and you have this in INSTALLED_APPS:

'django.contrib.staticfiles',

then use this in your template:

{% load staticfiles %}
    <link rel="stylesheet" type="text/css" href="{% static "css/bootstrap.css" %}">

more details: https://docs.djangoproject.com/en/dev/howto/static-files/

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Daniel, Thank you for your answer, Unfortunately I have most exactly the same in the setting files only the templates I have include your what you wrote, I have the content but the design is not what is in Bootstrap just display the content in the left hand.
BASE_DIR = os.path.dirname(os.path.dirname(file)) INSTALLED_APPS = ( 'django.contrib.staticfiles', 'join', 'south', ) STATIC_URL = '/static/' TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'static', 'templates'), ) MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'static', 'static-only') STATICFIELS_DIR = ( os.path.join(BASE_DIR, '/var/www/static', '/var/www/static'), ) that is all my settings file
I don't quite understand what you mean.what's in your template? maybe you could check in this docs.djangoproject.com/en/dev/howto/static-files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.