mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 09:57:55 +03:00 
			
		
		
		
	Merge branch 'refs/heads/master' into #1408
This commit is contained in:
		
						commit
						645ef9895f
					
				| 
						 | 
					@ -24,7 +24,7 @@ For example:
 | 
				
			||||||
    from myapp.serializers import PurchaseSerializer
 | 
					    from myapp.serializers import PurchaseSerializer
 | 
				
			||||||
    from rest_framework import generics
 | 
					    from rest_framework import generics
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class PurchaseList(generics.ListAPIView)
 | 
					    class PurchaseList(generics.ListAPIView):
 | 
				
			||||||
        serializer_class = PurchaseSerializer
 | 
					        serializer_class = PurchaseSerializer
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
        def get_queryset(self):
 | 
					        def get_queryset(self):
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ For example if your URL config contained an entry like this:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You could then write a view that returned a purchase queryset filtered by the username portion of the URL:
 | 
					You could then write a view that returned a purchase queryset filtered by the username portion of the URL:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class PurchaseList(generics.ListAPIView)
 | 
					    class PurchaseList(generics.ListAPIView):
 | 
				
			||||||
        serializer_class = PurchaseSerializer
 | 
					        serializer_class = PurchaseSerializer
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
        def get_queryset(self):
 | 
					        def get_queryset(self):
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ A final example of filtering the initial queryset would be to determine the init
 | 
				
			||||||
 | 
					
 | 
				
			||||||
We can override `.get_queryset()` to deal with URLs such as `http://example.com/api/purchases?username=denvercoder9`, and filter the queryset only if the `username` parameter is included in the URL:
 | 
					We can override `.get_queryset()` to deal with URLs such as `http://example.com/api/purchases?username=denvercoder9`, and filter the queryset only if the `username` parameter is included in the URL:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class PurchaseList(generics.ListAPIView)
 | 
					    class PurchaseList(generics.ListAPIView):
 | 
				
			||||||
        serializer_class = PurchaseSerializer
 | 
					        serializer_class = PurchaseSerializer
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
        def get_queryset(self):
 | 
					        def get_queryset(self):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -164,7 +164,7 @@ class Field(object):
 | 
				
			||||||
        Called to set up a field prior to field_to_native or field_from_native.
 | 
					        Called to set up a field prior to field_to_native or field_from_native.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        parent - The parent serializer.
 | 
					        parent - The parent serializer.
 | 
				
			||||||
        model_field - The model field this field corresponds to, if one exists.
 | 
					        field_name - The name of the field being initialized.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        self.parent = parent
 | 
					        self.parent = parent
 | 
				
			||||||
        self.root = parent.root or parent
 | 
					        self.root = parent.root or parent
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user