mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-10-31 07:57:55 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			15 lines
		
	
	
		
			458 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
		
			458 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from djangorestframework.resources import ModelResource
 | |
| from djangorestframework.reverse import reverse
 | |
| from modelresourceexample.models import MyModel
 | |
| 
 | |
| 
 | |
| class MyModelResource(ModelResource):
 | |
|     model = MyModel
 | |
|     fields = ('foo', 'bar', 'baz', 'url')
 | |
|     ordering = ('created',)
 | |
| 
 | |
|     def url(self, instance):
 | |
|         return reverse('model-resource-instance',
 | |
|                        kwargs={'id': instance.id},
 | |
|                        request=self.request)
 |