Makes admin urls work with Django 1.3 and adds a hint if no index page is defined

EmailTemplateFixes
Denis Krienbühl 2011-12-14 14:14:09 +01:00
parent db8113014c
commit f946ca1a3b
2 changed files with 23 additions and 15 deletions

View File

@ -1,15 +1,21 @@
# Create your views here.
from django.shortcuts import render_to_response, get_object_or_404
from django.shortcuts import render_to_response
from django import settings
from django.template import RequestContext
from django import http
from django.utils import translation
from models import Page
def page(request, page):
p = get_object_or_404(Page, slug=page)
if not p.public:
raise Http404
return render_to_response("page.html", { "request" : request, "page":p, }, context_instance = RequestContext(request) )
try:
p = Page.objects.get(slug=page, public=True)
except Page.DoesNotExist:
raise http.Http404('%s page requested but not found' % page)
return render_to_response("page.html",
{ "request" : request, "page" : p, },
context_instance = RequestContext(request)
)
def langpage(request, lang, page):
translation.activate_language(lang)

View File

@ -1,19 +1,21 @@
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'q/', include('questionnaire.urls')),
(r'^take/(?P<questionnaire_id>[0-9]+)/$', 'questionnaire.views.generate_run'),
(r'^$', 'page.views.page', {'page' : 'index'}),
(r'^(?P<page>.*)\.html$', 'page.views.page'),
(r'^(?P<lang>..)/(?P<page>.*)\.html$', 'page.views.langpage'),
url(r'q/', include('questionnaire.urls')),
url(r'^take/(?P<questionnaire_id>[0-9]+)/$', 'questionnaire.views.generate_run'),
url(r'^$', 'page.views.page', {'page' : 'index'}),
url(r'^(?P<page>.*)\.html$', 'page.views.page'),
url(r'^(?P<lang>..)/(?P<page>.*)\.html$', 'page.views.langpage'),
(r'^setlang/$', 'questionnaire.views.set_language'),
url(r'^setlang/$', 'questionnaire.views.set_language'),
(r'^media/(.*)', 'django.views.static.serve',
url(r'^media/(.*)', 'django.views.static.serve',
{ 'document_root' : settings.MEDIA_ROOT }),
(r'^admin/(.*)', admin.site.root),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)