urls.py 1.2 KB
Newer Older
Christophe Siraut's avatar
Christophe Siraut committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
from django.views.generic import DetailView
from django.shortcuts import get_object_or_404
from content.models import Page
from general.models import Settings
from django.contrib import admin
admin.autodiscover()

class HomepageDetail(DetailView):
    model = Page
    def get_object(self):
        settings = Settings.objects.get(pk=1)
        if settings.home_page:
            return get_object_or_404(Page, pk=settings.home_page.pk)
        return None

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'flyers.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),
    url(r'^admin/', include(admin.site.urls)),
    #url(r'^ckeditor/', include('ckeditor.urls')),
    url(r'^ckeditor/', include('flyers.urls_ckeditor')),
    #url(r'^$', TemplateView.as_view(template_name='homepage.html')),
    url(r'^$', HomepageDetail.as_view()),
    url(r'^(?P<slug>.+)/$', DetailView.as_view(model=Page)),
)

import settings
if settings.DEBUG:
    urlpatterns += patterns('',
        url(r'^media/(?P<path>.*)$',
            'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT, }),
    )