mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-10-31 07:57:55 +03:00 
			
		
		
		
	
							parent
							
								
									126cadf27e
								
							
						
					
					
						commit
						a798a5350a
					
				|  | @ -48,6 +48,7 @@ You can determine your currently installed version using `pip freeze`: | |||
| * Filtering backends are now applied to the querysets for object lookups as well as lists.  (Eg you can use a filtering backend to control which objects should 404) | ||||
| * Deal with error data nicely when deserializing lists of objects. | ||||
| * Extra override hook to configure `DjangoModelPermissions` for unauthenticated users. | ||||
| * Bugfix: Fix regression which caused extra database query on paginated list views. | ||||
| * Bugfix: Fix pk relationship bug for some types of 1-to-1 relations. | ||||
| * Bugfix: Workaround for Django bug causing case where `Authtoken` could be registered for cascade delete from `User` even if not installed. | ||||
| 
 | ||||
|  |  | |||
|  | @ -26,12 +26,14 @@ def is_simple_callable(obj): | |||
|     """ | ||||
|     True if the object is a callable that takes no arguments. | ||||
|     """ | ||||
|     try: | ||||
|         args, _, _, defaults = inspect.getargspec(obj) | ||||
|     except TypeError: | ||||
|     function = inspect.isfunction(obj) | ||||
|     method = inspect.ismethod(obj) | ||||
| 
 | ||||
|     if not (function or method): | ||||
|         return False | ||||
|     else: | ||||
|         len_args = len(args) if inspect.isfunction(obj) else len(args) - 1 | ||||
| 
 | ||||
|     args, _, _, defaults = inspect.getargspec(obj) | ||||
|     len_args = len(args) if function else len(args) - 1 | ||||
|     len_defaults = len(defaults) if defaults else 0 | ||||
|     return len_args <= len_defaults | ||||
| 
 | ||||
|  |  | |||
|  | @ -73,6 +73,8 @@ class IntegrationTestPagination(TestCase): | |||
|         GET requests to paginated ListCreateAPIView should return paginated results. | ||||
|         """ | ||||
|         request = factory.get('/') | ||||
|         # Note: Database queries are a `SELECT COUNT`, and `SELECT <fields>` | ||||
|         with self.assertNumQueries(2): | ||||
|             response = self.view(request).render() | ||||
|         self.assertEqual(response.status_code, status.HTTP_200_OK) | ||||
|         self.assertEqual(response.data['count'], 26) | ||||
|  | @ -81,6 +83,7 @@ class IntegrationTestPagination(TestCase): | |||
|         self.assertEqual(response.data['previous'], None) | ||||
| 
 | ||||
|         request = factory.get(response.data['next']) | ||||
|         with self.assertNumQueries(2): | ||||
|             response = self.view(request).render() | ||||
|         self.assertEqual(response.status_code, status.HTTP_200_OK) | ||||
|         self.assertEqual(response.data['count'], 26) | ||||
|  | @ -89,6 +92,7 @@ class IntegrationTestPagination(TestCase): | |||
|         self.assertNotEqual(response.data['previous'], None) | ||||
| 
 | ||||
|         request = factory.get(response.data['next']) | ||||
|         with self.assertNumQueries(2): | ||||
|             response = self.view(request).render() | ||||
|         self.assertEqual(response.status_code, status.HTTP_200_OK) | ||||
|         self.assertEqual(response.data['count'], 26) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user