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
bcd2caf5
Commit
bcd2caf5
authored
Oct 04, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abstract out the app_label on test models
parent
a02707e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
12 deletions
+52
-12
docs/api-guide/fields.md
+43
-0
rest_framework/tests/models.py
+9
-12
No files found.
docs/api-guide/fields.md
0 → 100644
View file @
bcd2caf5
<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/
rest_framework/tests/models.py
View file @
bcd2caf5
...
...
@@ -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
.
"""
text
=
models
.
CharField
(
max_length
=
100
,
default
=
'anchor'
)
class
Meta
:
app_label
=
'rest_framework'
abstract
=
True
class
BasicModel
(
models
.
Model
):
text
=
models
.
CharField
(
max_length
=
100
)
class
Anchor
(
RestFramework
Model
):
text
=
models
.
CharField
(
max_length
=
100
,
default
=
'anchor'
)
class
Meta
:
app_label
=
'rest_framework'
class
BasicModel
(
RestFrameworkModel
):
text
=
models
.
CharField
(
max_length
=
100
)
class
ManyToManyModel
(
models
.
Model
):
rel
=
models
.
ManyToManyField
(
Anchor
)
class
Meta
:
app_label
=
'rest_framework'
class
ManyToManyModel
(
RestFrameworkModel
)
:
rel
=
models
.
ManyToManyField
(
Anchor
)
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