diff options
| author | django-bot <ops@djangoproject.com> | 2023-02-28 20:53:28 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-03-01 13:03:56 +0100 |
| commit | 14459f80ee3a9e005989db37c26fd13bb6d2fab2 (patch) | |
| tree | eb62429ed696ed3a5389f3a676aecfc6d15a99cc /docs/topics/conditional-view-processing.txt | |
| parent | 6015bab80e28aef2669f6fac53423aa65f70cb08 (diff) | |
Fixed #34140 -- Reformatted code blocks in docs with blacken-docs.
Diffstat (limited to 'docs/topics/conditional-view-processing.txt')
| -rw-r--r-- | docs/topics/conditional-view-processing.txt | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/topics/conditional-view-processing.txt b/docs/topics/conditional-view-processing.txt index 6a524c93a6..2447697de4 100644 --- a/docs/topics/conditional-view-processing.txt +++ b/docs/topics/conditional-view-processing.txt @@ -71,9 +71,11 @@ Suppose you have this pair of models, representing a small blog system:: import datetime from django.db import models + class Blog(models.Model): ... + class Entry(models.Model): blog = models.ForeignKey(Blog, on_delete=models.CASCADE) published = models.DateTimeField(default=datetime.datetime.now) @@ -92,6 +94,7 @@ for your front page view:: from django.views.decorators.http import condition + @condition(last_modified_func=latest_entry) def front_page(request, blog_id): ... @@ -135,6 +138,8 @@ using one of these decorators:: def front_page(request, blog_id): ... + + front_page = last_modified(latest_entry)(front_page) Use ``condition`` when testing both conditions @@ -152,6 +157,7 @@ this would lead to incorrect behavior. def my_view(request): ... + # End of bad code. The first decorator doesn't know anything about the second and might |
