mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Added docs, integer fields and refactored models.TextField to use CharField
I realized that per the django forms, there is no need for a separate TextField, an unlimited CharField is perfectly good. Also added default field for the different IntegerField types
This commit is contained in:
parent
afbc9684f2
commit
c942726509
|
@ -73,18 +73,35 @@ These fields represent basic datatypes, and support both reading and writing val
|
|||
|
||||
## BooleanField
|
||||
|
||||
A Boolean representation, corresponds to `django.db.models.fields.BooleanField`.
|
||||
|
||||
## CharField
|
||||
|
||||
A text representation, optionally validates the text to be shorter than `max_length` and longer than `min_length`, corresponds to `django.db.models.fields.CharField`
|
||||
or `django.db.models.fields.TextField`.
|
||||
|
||||
**Signature:** `CharField([max_length=<Integer>[, min_length=<Integer>]])`
|
||||
|
||||
## EmailField
|
||||
|
||||
A text representation, validates the text to be a valid e-mail adress. Corresponds to `django.db.models.fields.EmailField`
|
||||
|
||||
## DateField
|
||||
|
||||
A date representation. Corresponds to `django.db.models.fields.DateField`
|
||||
|
||||
## DateTimeField
|
||||
|
||||
A date and time representation. Corresponds to `django.db.models.fields.DateTimeField`
|
||||
|
||||
## IntegerField
|
||||
|
||||
An integer representation. Corresponds to `django.db.models.fields.IntegerField`, `django.db.models.fields.SmallIntegerField`, `django.db.models.fields.PositiveIntegerField` and `django.db.models.fields.PositiveSmallIntegerField`
|
||||
|
||||
## FloatField
|
||||
|
||||
A floating point representation. Corresponds to `django.db.models.fields.FloatField`.
|
||||
|
||||
---
|
||||
|
||||
# Relational Fields
|
||||
|
|
|
@ -377,11 +377,14 @@ class ModelSerializer(Serializer):
|
|||
field_mapping = {
|
||||
models.FloatField: FloatField,
|
||||
models.IntegerField: IntegerField,
|
||||
models.PositiveIntegerField: IntegerField,
|
||||
models.SmallIntegerField: IntegerField,
|
||||
models.PositiveSmallIntegerField: IntegerField,
|
||||
models.DateTimeField: DateTimeField,
|
||||
models.DateField: DateField,
|
||||
models.EmailField: EmailField,
|
||||
models.CharField: CharField,
|
||||
models.TextField: TextField,
|
||||
models.TextField: CharField,
|
||||
models.CommaSeparatedIntegerField: CharField,
|
||||
models.BooleanField: BooleanField,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user