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/'
TEMPLATE_CONTEXT_PROCESSOR = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.media',
)
--------------------------------------------------------------------------------------------
views.py
from django.shortcuts import render_to_response
from blog.data.models import Entry
from django.template import RequestContext
def index(request):
entries = Entry.objects.published_entries().order_by('-id')
return render_to_response('homepage/index.html', {'entries': entries}, context_instance = RequestContext(request))
def about(request):
return render_to_response('homepage/about.html', context_instance = RequestContext(request))
def contact(request):
return render_to_response('homepage/contact.html', context_instance = RequestContext(request))
def archive(request):
return render_to_response('homepage/archive.html', context_instance = RequestContext(request))
--------------------------------------------------------------------------------------------
base.html
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% block js %}{% endblock %}
{% block css %}<link rel="stylesheet" href="{{ MEDIA_URL }}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>
Комментариев нет:
Отправить комментарий