Good day to all. Help to connect statics in django

Code setting.py

MEDIA_ROOT = 'c:/Python27/Scripts/todo/media/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/media/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = 'c:/Python27/Scripts/todo/collected_static/' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( 'c:/Python27/Scripts/todo/static/' # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths.) 
  • base.html <link rel = "stylesheet" href = "{{STATIC_URL}} css / style.css" media = "all" type = "text / css"> - damasco
  • you need to add url.py - damasco

2 answers 2

Oddly, this is why media in a folder with Python stored?

Here is an example from the working draft:

First, from the top, ask:

 import os PROJ_MODULE_ROOT = os.path.abspath(os.path.dirname(__file__)) ROOT = os.path.normpath(os.path.join(PROJ_MODULE_ROOT, "..")) root_path = lambda *args: os.path.join(ROOT, *args) path = lambda *args: os.path.join(PROJ_MODULE_ROOT, *args) 

then:

 MEDIA_ROOT = root_path('media') MEDIA_URL = '/media/' STATIC_ROOT = path('../../static/') STATIC_URL = '/static/' 

    Something you polusovoval strange here.

    Perhaps you did not register 'django.core.context_processors.static' in TEMPLATE_CONTEXT_PROCESSORS in settings.py, and therefore {{STATIC_URL}} you simply do not fill out.