diff options
author | lxf <sng@luxagraf.net> | 2022-05-15 09:28:50 -0400 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2022-05-15 09:28:50 -0400 |
commit | cb48e76ce2e1b78e8983a92cf5c85b5c4a953c7e (patch) | |
tree | 462fc664270fd9ff6a69b471809ae5d71b48a9f4 | |
parent | 7dfa81c42a219ea60e03539471272af65d5574bc (diff) |
page: change homepage to be static and rely on template
-rw-r--r-- | app/pages/views.py | 15 | ||||
-rw-r--r-- | config/base_urls.py | 4 |
2 files changed, 9 insertions, 10 deletions
diff --git a/app/pages/views.py b/app/pages/views.py index 7ea2439..4adebbf 100644 --- a/app/pages/views.py +++ b/app/pages/views.py @@ -22,19 +22,18 @@ class PageDetailTXTView(LuxDetailView): return 'pages/%s/page_detail.txt'% obj.site.name -class HomePageList(DetailView): +class HomePageView(DetailView): """ Return a main entry and list of Entries in reverse chronological order """ - model = HomePage + model = Page def get_template_names(self): - return ["pages/%s.html" % self.template_name, 'pages/homepage.html'] + return 'pages/homepage.html' - def get_context_data(self, **kwargs): + def get_queryset(self, **kwargs): # Call the base implementation first to get a context - context = super(HomePageList, self).get_context_data(**kwargs) - context['object_list'] = Post.objects.filter(post_type=PostType.HOMEPAGE).filter(status__exact=1).order_by('-pub_date')[1:9] - return context - + qs = super(HomePageView, self).get_queryset(**kwargs) + qs = Page.objects.filter(title="homepage") + return qs diff --git a/config/base_urls.py b/config/base_urls.py index 7bc3431..d306d44 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -5,7 +5,7 @@ from django.contrib import admin from django.contrib.sitemaps.views import sitemap from django.views.generic.base import RedirectView -from pages.views import PageDetailView, PageDetailTXTView, HomePageList +from pages.views import PageDetailView, PageDetailTXTView, HomePageView from posts.models import PostSitemap from pages.models import PageSitemap import builder.views @@ -35,7 +35,7 @@ urlpatterns = [ path(r'<slug>.txt', PageDetailTXTView.as_view()), path(r'<slug>', include('pages.urls', namespace='pages')), path(r'<path>/<slug>/', PageDetailView.as_view()), - path(r'', HomePageList.as_view(), {'pk':1,}, name="homepage"), + path(r'', HomePageView.as_view(), {'pk':1,}, name="homepage"), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |