I’ve found a lot of different examples on how to do this, all slightly different in what they say to set as the MEDIA_URL, STATIC_URL, MEDIA_ROOT, MEDIA_URL. My project files are structured as follows:
myproject/
images/ (user-uploaded)
media/ (empty so far)
settings.py
static/
css/
styles.css
fonts/
templates/
auth/
base.html
login.html
index.html
urls.py
And of course there’s app directories in the root folder. For my images to show up on the index template, I did this:
urls.py:
from django.conf import settings
(r'%s(?P<path>.*)' % settings.MEDIA_URL[1:], 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
settings.py (these were the default):
MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
The site I’m making is on the front end just a single page. How do I get the stylesheet to link properly? I’m not really sure what the difference is between all these directory settings or why I would use one over another… or what the best way (if there is one) is to structure the whole thing, with where to put css, javascript, fonts, static images, user-uploaded images, etc.
Media is for user uploaded files, static – for your CSS and and other files, so you must create there directories for your static files like js and css.
You’ve done right all things, because something like this in official documentation in Django. I’ll leave how my friend told me to do, to server static files in few machines: