Skip to content

Corrected code examples in topics docs. #19697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Corrected code examples in topics docs.
  • Loading branch information
Rohit10jr authored and sarahboyce committed Aug 11, 2025
commit a70fd7c5f90ff30a6cb427a78ff171859383410b
4 changes: 2 additions & 2 deletions docs/topics/class-based-views/generic-editing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/pagination.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down