1
0
mirror of https://github.com/django/django.git synced 2025-08-21 01:09:13 +00:00

Corrected code examples in topics docs.

This commit is contained in:
Rohit 2025-08-11 09:09:16 +02:00 committed by Sarah Boyce
parent 7a80e29fea
commit fa804d0d14
3 changed files with 4 additions and 4 deletions

View File

@ -303,7 +303,7 @@ preference, use :func:`django.http.HttpRequest.get_preferred_type`::
def form_invalid(self, form):
response = super().form_invalid(form)
accepted_type = request.get_preferred_type(self.accepted_media_types)
accepted_type = self.request.get_preferred_type(self.accepted_media_types)
if accepted_type == "text/html":
return response
elif accepted_type == "application/json":
@ -314,7 +314,7 @@ preference, use :func:`django.http.HttpRequest.get_preferred_type`::
# it might do some processing (in the case of CreateView, it will
# call form.save() for example).
response = super().form_valid(form)
accepted_type = request.get_preferred_type(self.accepted_media_types)
accepted_type = self.request.get_preferred_type(self.accepted_media_types)
if accepted_type == "text/html":
return response
elif accepted_type == "application/json":

View File

@ -70,7 +70,7 @@ location (:setting:`MEDIA_ROOT` if you are using the default
>>> from django.conf import settings
>>> initial_path = car.photo.path
>>> car.photo.name = "cars/chevy_ii.jpg"
>>> new_path = settings.MEDIA_ROOT + car.photo.name
>>> new_path = os.path.join(settings.MEDIA_ROOT, car.photo.name)
>>> # Move the file on the filesystem
>>> os.rename(initial_path, new_path)
>>> car.save()

View File

@ -31,7 +31,7 @@ accessing the items for each page:
>>> p.num_pages
2
>>> type(p.page_range)
<class 'range_iterator'>
<class 'range'>
>>> p.page_range
range(1, 3)