browse url and template
This commit is contained in:
parent
c0750fdb30
commit
48a0d26745
|
@ -0,0 +1,17 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load helper_tags %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
{% block languagecode %}
|
||||
{{ LANGUAGE_CODE }}
|
||||
{% endblock languagecode %}
|
||||
{% block title %}
|
||||
{% translate "cscherr.de" %} - {% translate "Blog" %}
|
||||
{% endblock title %}
|
||||
{% block nav %}
|
||||
{% include 'nav.html' %}
|
||||
{% endblock nav %}
|
||||
{% block main %}
|
||||
<div class="container-xl">{{ category }}</div>
|
||||
{% include 'blog/featured.html' %}
|
||||
{% endblock main %}
|
|
@ -5,7 +5,6 @@ from . import views
|
|||
app_name: str = "blog"
|
||||
urlpatterns = [
|
||||
path("", views.Index.as_view(), name="index"),
|
||||
path("categories", views.CategoryList.as_view(), name="category_list"),
|
||||
path("<slug:slug>", views.ArticleList.as_view(), name="article_list"),
|
||||
path("browse", views.Browse.as_view(), name="browse"),
|
||||
path("<slug:category>/<slug:slug>", views.Post.as_view(), name="post"),
|
||||
]
|
||||
|
|
|
@ -21,7 +21,6 @@ class Index(TemplateView, SearchableView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['featured_posts'] = BlogPost.objects.filter(featured=True, public=True)
|
||||
logger.debug(f"loaded featured posts: {context['featured_posts']}")
|
||||
return context
|
||||
|
||||
class Post(DetailView):
|
||||
|
@ -36,25 +35,9 @@ class Post(DetailView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['featured_posts'] = BlogPost.objects.filter(featured=True)
|
||||
logger.debug(f"loaded featured posts: {context['featured_posts']}")
|
||||
return context
|
||||
|
||||
class CategoryList(ListView):
|
||||
"""
|
||||
Scroll through a list of blog Categories
|
||||
"""
|
||||
|
||||
model=Category
|
||||
template_name = "blog/categories.html"
|
||||
context_object_name = "categories"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['featured_posts'] = BlogPost.objects.filter(featured=True)
|
||||
logger.debug(f"loaded featured posts: {context['featured_posts']}")
|
||||
return context
|
||||
|
||||
class ArticleList(ListView):
|
||||
class Browse(ListView):
|
||||
"""
|
||||
Scroll through a list of blog posts
|
||||
|
||||
|
@ -63,11 +46,10 @@ class ArticleList(ListView):
|
|||
"""
|
||||
|
||||
model=BlogPost
|
||||
template_name = "blog/posts.html"
|
||||
template_name = "blog/browse.html"
|
||||
context_object_name = "posts"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['featured_posts'] = BlogPost.objects.filter(featured=True)
|
||||
logger.debug(f"loaded featured posts: {context['featured_posts']}")
|
||||
return context
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="{% url 'blog:index' %}">{% translate "Start" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'blog:category_list' %}">{% translate "category list" %}</a></li>
|
||||
<li><a class="dropdown-item" href="{% url 'blog:browse' %}">{% translate "Browse" %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
|
|
Loading…
Reference in New Issue