mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 01:47:59 +03:00 
			
		
		
		
	Abstract out the app_label on test models
This commit is contained in:
		
							parent
							
								
									a02707e12f
								
							
						
					
					
						commit
						bcd2caf559
					
				
							
								
								
									
										43
									
								
								docs/api-guide/fields.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								docs/api-guide/fields.md
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
<a class="github" href="fields.py"></a>
 | 
			
		||||
 | 
			
		||||
# Serializer fields
 | 
			
		||||
 | 
			
		||||
> Flat is better than nested.
 | 
			
		||||
>
 | 
			
		||||
> — [The Zen of Python][cite]
 | 
			
		||||
 | 
			
		||||
# Generic Fields
 | 
			
		||||
 | 
			
		||||
## Field
 | 
			
		||||
 | 
			
		||||
## ModelField
 | 
			
		||||
 | 
			
		||||
# Typed Fields
 | 
			
		||||
 | 
			
		||||
## BooleanField
 | 
			
		||||
 | 
			
		||||
## CharField
 | 
			
		||||
 | 
			
		||||
## EmailField
 | 
			
		||||
 | 
			
		||||
## DateField
 | 
			
		||||
 | 
			
		||||
## DateTimeField
 | 
			
		||||
 | 
			
		||||
## IntegerField
 | 
			
		||||
 | 
			
		||||
## FloatField
 | 
			
		||||
 | 
			
		||||
# Relational Fields
 | 
			
		||||
 | 
			
		||||
Relational fields are used to represent model relationships.
 | 
			
		||||
 | 
			
		||||
## PrimaryKeyRelatedField
 | 
			
		||||
 | 
			
		||||
## ManyPrimaryKeyRelatedField
 | 
			
		||||
 | 
			
		||||
## HyperlinkedRelatedField
 | 
			
		||||
 | 
			
		||||
## ManyHyperlinkedRelatedField
 | 
			
		||||
 | 
			
		||||
[cite]: http://www.python.org/dev/peps/pep-0020/
 | 
			
		||||
| 
						 | 
				
			
			@ -28,25 +28,22 @@ from django.db import models
 | 
			
		|||
#             'pk': self.id
 | 
			
		||||
#         })
 | 
			
		||||
 | 
			
		||||
class Anchor(models.Model):
 | 
			
		||||
class RestFrameworkModel(models.Model):
 | 
			
		||||
    """
 | 
			
		||||
    A simple model to use as the target of relationships for other test models.
 | 
			
		||||
    Base for test models that sets app_label, so they play nicely.
 | 
			
		||||
    """
 | 
			
		||||
    class Meta:
 | 
			
		||||
        app_label = 'rest_framework'
 | 
			
		||||
        abstract = True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Anchor(RestFrameworkModel):
 | 
			
		||||
    text = models.CharField(max_length=100, default='anchor')
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        app_label = 'rest_framework'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BasicModel(models.Model):
 | 
			
		||||
class BasicModel(RestFrameworkModel):
 | 
			
		||||
    text = models.CharField(max_length=100)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        app_label = 'rest_framework'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ManyToManyModel(models.Model):
 | 
			
		||||
class ManyToManyModel(RestFrameworkModel):
 | 
			
		||||
    rel = models.ManyToManyField(Anchor)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        app_label = 'rest_framework'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user