Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def article_list_all(request):
page = page_for_app_request(request)
page.activate_language(request)
return render_list(
request, Article.objects.filter(category=page.application), {"page": page}
)
def article_detail(request, pk):
page = page_for_app_request(request)
page.activate_language(request)
return render_detail(request, get_object_or_404(Article, pk=pk), {"page": page})
def article_list(request):
page = page_for_app_request(request)
page.activate_language(request)
return render_list(
request,
Article.objects.filter(category=page.application),
{"page": page},
paginate_by=5,
)
def article_detail(request, year, slug):
page = page_for_app_request(request)
page.activate_language(request)
return render_detail(
request,
# We are NOT filtering for the current app. If, for example, the
# blog application is inactive, we'd rather show the article in
# the publication app than not at all. Of course if this behavior
# isn't a good fit for you, simply add ``category=page.application``
# here.
get_object_or_404(
Article.objects.published(),
publication_date__year=year,
slug=slug,
),
{'page': page},
)
def article_list(request):
page = page_for_app_request(request)
page.activate_language(request)
return render_list(
request,
# Only show articles for the current app.
Article.objects.published().filter(
category=page.application,
).prefetch_related('images'),
{'page': page},
paginate_by=10,
)