views.py:
from django.template.loader import get_template from django.template import Context from django.http import HttpResponse def render_tpl(request): t = get_template('html/index.html') html = t.render(Context()) return HttpResponse(html)
urls.py:
from django.conf.urls.defaults import patterns, include, url from itchallenges.views import render_tpl from django.contrib.staticfiles.urls import staticfiles_urlpatterns # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', ('^$', render_tpl), ) urlpatterns += staticfiles_urlpatterns()
settings.py (выборочно):
MEDIA_ROOT = '' MEDIA_URL = '' STATIC_ROOT = "/home/oleg-admin/django/itchallenges/static/" STATIC_URL = "/static/" ADMIN_MEDIA_PREFIX = "/static/admin/" STATICFILES_DIRS = ( "/home/oleg-admin/django/itchallenges/static/", ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'tpl/beadysite').replace('\\','/'), ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', )
Пытаюсь подключить CSS так: <link href=“{{ STATIC_URL }}css/style.css” rel=“stylesheet” type=“text/css” media=“screen” />
Вся статика собрана в папке static (там находятся папки соответственно css и images), которая находится в корневой папке проекта. Что же я делаю не так?