base.html
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% block js %}{% endblock %}
{% block css %}<link rel="stylesheet" href="/static/css/main.css" type="text/css" media="screen" />{% endblock %}
</head>
<body>
<div id="top">My Blog</div>
<div id="navi">{% block navi %}{% endblock %}</div>
<div id="content">{% block content %}{% endblock %}</div>
<div id="footer">{% block footer %}{% endblock %}</div>
</body>
</html>
--------------------------------------------------------------------------------------------
settings.py
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), 'static/'))
# 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 = '/static/'
# 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 = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'blog.data',
)
--------------------------------------------------------------------------------------------
urls.py
from django.conf.urls.defaults import patterns, include, url
from blog import settings
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'blog.homepage.views.index', name = 'homepage_index'),
url(r'^about/$', 'blog.homepage.views.about', name = 'homepage_about'),
url(r'^contact/$', 'blog.homepage.views.contact', name = 'homepage_contact'),
url(r'^archive/$', 'blog.homepage.views.archive', name = 'homepage_archive'),
url(r'^admin/', include(admin.site.urls)),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
Комментариев нет:
Отправить комментарий