mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Corrected code examples in topics docs.
This commit is contained in:
		| @@ -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": | ||||
|   | ||||
| @@ -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() | ||||
|   | ||||
| @@ -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) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user