mirror of
https://github.com/django/django.git
synced 2025-08-31 15:57:45 +00:00
Fixed #34140 -- Reformatted code blocks in docs with blacken-docs.
This commit is contained in:
parent
6015bab80e
commit
14459f80ee
193 changed files with 5797 additions and 4481 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue