2

I have a simple website running on Django. When I load Bootstrap css files, the page loads the formatting just fine. But I try to load the css file I have created and saved in the same folder as the Bootstrap css files, the file does not load. See the file here http://jsfiddle.net/zptkvx5c/ In both case I am making reference to the file in the html head.

<link href="{% static "css/mystyles.css" %}" rel="stylesheet"> 
<!--  <link href="{% static "css/bootstrap.css" %}" rel="stylesheet">  --> This one works    

Could anyone assist to fix this?

Update: I have tried to hardcode the url and still it doesn't work

5
  • 1
    are you sure that mystyles.css file is present in css directory? Did you do python manage.py collectstatic after adding this file? Commented Sep 26, 2015 at 10:21
  • Yes, I have confirmed the mystyles.css is in the folder. I have not run collectstatic. I am using the django development server with debug=true it seems to load Bootstrap ok. Any personal css files will only be served with the collectstatic command? Commented Sep 26, 2015 at 10:48
  • What does it say in the js console? Also, try swapping the order, bootstrap.css first and then mystyles.css Commented Sep 26, 2015 at 11:15
  • Thank you @ ham-sandwich I have never used the js console before. I have realised I have been trying to solve the problem and made a mistake. Commented Sep 26, 2015 at 11:49
  • I had made an app level static folder (toplevel/appfolder/static/appfolder) and put a bootstrap folder there. This is the one that was being loaded. However I was trying to set up a project level static folder where I had put another Bootstrap folder and the styles.css file I was trying to load. (projectfolder/staticfolder) Perhaps can you advise me how to reference the project level static folder? Commented Sep 26, 2015 at 12:19

1 Answer 1

1

you can do this one:

<link href="css/mystyles.css" rel="stylesheet" /> 

or

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

This one works

SEE THE PAGE

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

3 Comments

This does not work, shouldn't there be a reference to the static folder?
Now see My answer sir@Avagut
Thank you @ivin raj does this reference an app level static folder or a project level static folder ie. where I can put static files to be used in all apps?

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.