-1

enter image description here

I'm working locally on a django project with bootstrap . The structure screenshot is above:

I have the following in index.html:

<!DOCTYPE html>
<html lang="en">    

<head>  

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="" />   

    <title>Landing Page - Start Bootstrap Theme</title> 

    <!-- Bootstrap Core CSS -->
    {% load staticfiles %}
    <link href="{% static "css/bootstrap.min.css" %}" rel="stylesheet" />   

    <!-- Custom CSS -->
    <link href="{% static "css/landing-page.css" %}" rel="stylesheet" />    

    <!-- Custom Fonts -->
    <link href="{% static "font-awesome-4.2.0/css/font-awesome.min.css" %}" rel="stylesheet" type="text/css" />
    <link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css" />  

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->    

</head>

In my settings.py I have:

STATIC_URL = '/static/'

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR,  'templates'),

When I open "http://onetwentyseven.0.0.1:8000/index/", I see the html but the bootstrap css styling is not present. in dev tools I see:

enter image description here

How can I fix the CSS paths?

3
  • Those paths look fine to me, are you sure they need fixing? Seems more likely that you just don't have anything serving your assets. Commented Dec 5, 2014 at 18:51
  • ... that means take a look to project urls.py. Here stackoverflow.com/questions/26653721/… some recommendations Commented Dec 5, 2014 at 19:27
  • Thanks, but it did not work Commented Dec 6, 2014 at 3:20

1 Answer 1

0

This seems to be a syntax error. If you move the css directory from static>app1>css to static>css. It should work just fine

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

3 Comments

But isn't that against best practices? I think I've read in multiple places that the best way is to have a static subfolder for each app
If you want subfolders i would do: static>css. then in css have you bootstrap.css and the directory 'app1' which contains 'landing-page.css' then in your template change <link href="{% static "css/landing-page.css" %}" rel="stylesheet" /> to <link href="{% static "css/app1/landing-page.css" %}" rel="stylesheet" />
thanks Tim, I made the changes but it did not work. I found agiliq.com/blog/2013/03/serving-static-files-in-django/#servee which helps my understanding

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.