Django Tutorial for Beginners – 25 – Bootstrap and Static Files


[ad_1]
https://i.ytimg.com/vi/Dv15y5CgCyE/hqdefault.jpg



Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Original source


32 responses to “Django Tutorial for Beginners – 25 – Bootstrap and Static Files”

  1. For those who are having issue with the background.png not showing up. Make sure the background.png file is not corrupted. I downloaded it from bucky's repo and it looks corrupted that's why it isnt showing the the page. I download different image with the same background.png and it worked.

  2. The CSS Background wasn't changing for me and I must have spent 40 minutes looking for the problem, restarting my server etc. My style.css folder was in the images directory instead of the music directory. I feel like an idiot!

  3. Interesting method: I believe from the Django website and maybe some other source it states that you should add the following line to the settings.py file:

    STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

    Then you can reference the source as follows:

    index.html
    <link rel="stylesheet" type="text/css" href="/static/music/style.css">

    style.css

    background: white url("/static/music/images/background.png");

    It's just a question which is better? I will stick to your method unless told otherwise!

  4. What is the accepted way of laying out a django project with many apps? For example, I have a main site with sidebar navigation containing links to the apps within my project. Should I create subapps or should I create a main app that manages the link navigation? I ask at this point in your tutorials because I would rather have a master layout page for my static includes much the way an Asp.Net MVC app works. Perhaps this is touched on in another lesson?

  5. Quick question, if the site is going to grow to a full produciton – wouldnt it be better to use Django's staticfiles app?
    As in having a static folder i the root of the project, and using manage.py collectstatic to copy all the contents into this one folder defined as STATIC_ROOT in the settings.py

    https://docs.djangoproject.com/en/1.9/ref/contrib/staticfiles/

    EDIT: My bad, seems like this is the way to do it, and rather use the collectstatic later on when publishing the project. So development should be done just as you've shown.

Leave a Reply