Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
7e702439
Commit
7e702439
authored
Mar 01, 2013
by
Stephan Groß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs update - part 1
parent
876a58e8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
18 deletions
+63
-18
docs/api-guide/fields.md
+18
-6
docs/api-guide/settings.md
+35
-0
docs/topics/release-notes.md
+1
-3
rest_framework/fields.py
+9
-9
No files found.
docs/api-guide/fields.md
View file @
7e702439
...
@@ -185,18 +185,20 @@ Corresponds to `django.forms.fields.RegexField`
...
@@ -185,18 +185,20 @@ Corresponds to `django.forms.fields.RegexField`
A date representation.
A date representation.
Uses
`DATE_INPUT_FORMATS`
to validate date.
Optionally takes
`format`
as parameter to replace the matching pattern.
Optionally takes
`format`
as parameter to replace the matching pattern.
Corresponds to
`django.db.models.fields.DateField`
Corresponds to
`django.db.models.fields.DateField`
**Signature:**
`DateField(input_formats=None, output_format=False)`
-
`input_formats`
designates which input formats are supported. This will override the
`DATE_INPUT_FORMATS`
-
`output_format`
designates which output format will be used. This will override the
`DATE_OUTPUT_FORMAT`
## DateTimeField
## DateTimeField
A date and time representation.
A date and time representation.
Uses
`DATETIME_INPUT_FORMATS`
to validate date_time.
Optionally takes
`format`
as parameter to replace the matching pattern.
Optionally takes
`format`
as parameter to replace the matching pattern.
Corresponds to
`django.db.models.fields.DateTimeField`
Corresponds to
`django.db.models.fields.DateTimeField`
...
@@ -211,16 +213,26 @@ If you want to override this behavior, you'll need to declare the `DateTimeField
...
@@ -211,16 +213,26 @@ If you want to override this behavior, you'll need to declare the `DateTimeField
class Meta:
class Meta:
model = Comment
model = Comment
**Signature:**
`DateTimeField(input_formats=None, output_format=False)`
-
`input_formats`
designates which input formats are supported. This will override the
`DATETIME_INPUT_FORMATS`
-
`output_format`
designates which output format will be used. This will override the
`DATETIME_OUTPUT_FORMAT`
## TimeField
## TimeField
A time representation.
A time representation.
Uses
`TIME_INPUT_FORMATS`
to validate time.
Optionally takes
`format`
as parameter to replace the matching pattern.
Optionally takes
`format`
as parameter to replace the matching pattern.
Corresponds to
`django.db.models.fields.TimeField`
Corresponds to
`django.db.models.fields.TimeField`
**Signature:**
`TimeField(input_formats=None, output_format=False)`
-
`input_formats`
designates which input formats are supported. This will override the
`TIME_INPUT_FORMATS`
-
`output_format`
designates which output format will be used. This will override the
`TIME_OUTPUT_FORMAT`
## IntegerField
## IntegerField
An integer representation.
An integer representation.
...
...
docs/api-guide/settings.md
View file @
7e702439
...
@@ -174,4 +174,39 @@ The name of a parameter in the URL conf that may be used to provide a format suf
...
@@ -174,4 +174,39 @@ The name of a parameter in the URL conf that may be used to provide a format suf
Default:
`'format'`
Default:
`'format'`
## DATE_INPUT_FORMATS
Default:
(
'%Y-%m-%d', # '1984-07-31'
)
## DATE_OUTPUT_FORMAT
## DATETIME_INPUT_FORMATS
Default:
(
'%Y-%m-%d', # '1984-07-31'
'%Y-%m-%d %H:%M', # '1984-07-31 04:31'
'%Y-%m-%d %H:%M:%S', # '1984-07-31 04:31:59'
'%Y-%m-%d %H:%M:%S.%f', # '1984-07-31 04:31:59.000200'
)
## DATETIME_OUTPUT_FORMAT
## TIME_INPUT_FORMATS
Default:
(
'%H:%M', # '04:31'
'%H:%M:%S', # '04:31:59'
'%H:%M:%S.%f', # '04:31:59.000200'
)
## TIME_OUTPUT_FORMAT
[
cite
]:
http://www.python.org/dev/peps/pep-0020/
[
cite
]:
http://www.python.org/dev/peps/pep-0020/
docs/topics/release-notes.md
View file @
7e702439
...
@@ -44,9 +44,7 @@ You can determine your currently installed version using `pip freeze`:
...
@@ -44,9 +44,7 @@ You can determine your currently installed version using `pip freeze`:
*
Bugfix for serializer data being uncacheable with pickle protocol 0.
*
Bugfix for serializer data being uncacheable with pickle protocol 0.
*
Bugfixes for model field validation edge-cases.
*
Bugfixes for model field validation edge-cases.
*
Support `DATE_INPUT_FORMATS` for `DateField` validation
*
Support for custom input and output formats for `DateField`, `DateTimeField` and `TimeField`
*
Support `DATETIME_INPUT_FORMATS` for `DateTimeField` validation
*
Support `TIME_INPUT_FORMATS` for `TimeField` validation
### 2.2.1
### 2.2.1
...
...
rest_framework/fields.py
View file @
7e702439
...
@@ -452,9 +452,9 @@ class DateField(WritableField):
...
@@ -452,9 +452,9 @@ class DateField(WritableField):
}
}
empty
=
None
empty
=
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
input_formats
=
None
,
output_format
=
None
,
*
args
,
**
kwargs
):
self
.
input_formats
=
kwargs
.
pop
(
'input_formats'
,
api_settings
.
DATE_INPUT_FORMATS
)
self
.
input_formats
=
input_formats
or
api_settings
.
DATE_INPUT_FORMATS
self
.
output_format
=
kwargs
.
pop
(
'output_format'
,
api_settings
.
DATE_OUTPUT_FORMAT
)
self
.
output_format
=
output_format
or
api_settings
.
DATE_OUTPUT_FORMAT
super
(
DateField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
DateField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
from_native
(
self
,
value
):
def
from_native
(
self
,
value
):
...
@@ -499,9 +499,9 @@ class DateTimeField(WritableField):
...
@@ -499,9 +499,9 @@ class DateTimeField(WritableField):
}
}
empty
=
None
empty
=
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
input_formats
=
None
,
output_format
=
None
,
*
args
,
**
kwargs
):
self
.
input_formats
=
kwargs
.
pop
(
'input_formats'
,
api_settings
.
DATETIME_INPUT_FORMATS
)
self
.
input_formats
=
input_formats
or
api_settings
.
DATETIME_INPUT_FORMATS
self
.
output_format
=
kwargs
.
pop
(
'output_format'
,
api_settings
.
DATETIME_OUTPUT_FORMAT
)
self
.
output_format
=
output_format
or
api_settings
.
DATETIME_OUTPUT_FORMAT
super
(
DateTimeField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
DateTimeField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
from_native
(
self
,
value
):
def
from_native
(
self
,
value
):
...
@@ -552,9 +552,9 @@ class TimeField(WritableField):
...
@@ -552,9 +552,9 @@ class TimeField(WritableField):
}
}
empty
=
None
empty
=
None
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
input_formats
=
None
,
output_format
=
None
,
*
args
,
**
kwargs
):
self
.
input_formats
=
kwargs
.
pop
(
'input_formats'
,
api_settings
.
TIME_INPUT_FORMATS
)
self
.
input_formats
=
input_formats
or
api_settings
.
TIME_INPUT_FORMATS
self
.
output_format
=
kwargs
.
pop
(
'output_format'
,
api_settings
.
TIME_OUTPUT_FORMAT
)
self
.
output_format
=
output_format
or
api_settings
.
TIME_OUTPUT_FORMAT
super
(
TimeField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
TimeField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
from_native
(
self
,
value
):
def
from_native
(
self
,
value
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment