-
Notifications
You must be signed in to change notification settings - Fork 7
DOCSP-46325: Models #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
84a8757
DOCSP-46325: Models
norareidy cb862c5
edits
norareidy 2a91d96
more info
norareidy 22b96f1
edit
norareidy db2ed44
fixes
norareidy 3be1492
toc
norareidy 188ace2
snooty
norareidy 4fbefe4
remove unsupported fields
norareidy 412abb6
jib feedback
norareidy bdaff83
meta options
norareidy 7fd38fd
RM feedback
norareidy f191068
SR feedback
norareidy d4a6ece
Merge remote-tracking branch 'upstream/master' into DOCSP-46325-models
norareidy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# start-models | ||
from django.db import models | ||
|
||
class Movie(models.Model): | ||
title = models.CharField(max_length=200) | ||
plot = models.TextField(blank=True) | ||
runtime = models.IntegerField(default=0) | ||
released = models.DateTimeField("release date", null=True, blank=True) | ||
|
||
class Meta: | ||
db_table = "movies" | ||
managed = False | ||
|
||
def __str__(self): | ||
return self.title | ||
# end-models | ||
|
||
# start-json-field | ||
from django.db import models | ||
|
||
class Movie(models.Model): | ||
title = models.CharField(max_length=200) | ||
plot = models.TextField(blank=True) | ||
runtime = models.IntegerField(default=0) | ||
released = models.DateTimeField("release date", null=True, blank=True) | ||
imdb = models.JSONField(null=True, blank=True) | ||
|
||
class Meta: | ||
db_table = "movies" | ||
managed = False | ||
|
||
def __str__(self): | ||
return self.title | ||
# end-json-field | ||
|
||
# start-array-field | ||
from django.db import models | ||
from django_mongodb_backend.fields import ArrayField | ||
|
||
class Movie(models.Model): | ||
title = models.CharField(max_length=200) | ||
plot = models.TextField(blank=True) | ||
runtime = models.IntegerField(default=0) | ||
released = models.DateTimeField("release date", null=True, blank=True) | ||
genres = ArrayField( | ||
models.CharField(max_length=100), | ||
size=5, | ||
null=True, | ||
blank=True) | ||
|
||
class Meta: | ||
db_table = "movies" | ||
managed = False | ||
|
||
def __str__(self): | ||
return self.title | ||
# end-array-field | ||
|
||
# start-embedded-field | ||
from django.db import models | ||
from django_mongodb_backend.models import EmbeddedModel | ||
from django_mongodb_backend.fields import EmbeddedModelField | ||
|
||
class Award(EmbeddedModel): | ||
wins = models.IntegerField(default=0) | ||
nominations = models.IntegerField(default=0) | ||
text = models.CharField(max_length=100) | ||
|
||
class Meta: | ||
managed = False | ||
|
||
class Movie(models.Model): | ||
title = models.CharField(max_length=200) | ||
plot = models.TextField(blank=True) | ||
runtime = models.IntegerField(default=0) | ||
released = models.DateTimeField("release date", null=True, blank=True) | ||
awards = EmbeddedModelField(Award, null=True, blank=True) | ||
|
||
class Meta: | ||
db_table = "movies" | ||
managed = False | ||
|
||
def __str__(self): | ||
return self.title | ||
# end-embedded-field |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.. _django-model-data: | ||
|
||
=============== | ||
Model Your Data | ||
=============== | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 2 | ||
:class: singlecol | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: reference | ||
|
||
.. meta:: | ||
:description: Learn how to use Django MongoDB Backend to model MongoDB data. | ||
:keywords: field, query, collection, object | ||
|
||
.. toctree:: | ||
:titlesonly: | ||
:maxdepth: 1 | ||
|
||
Create Models </model-data/models> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming there are more pages to come that will be nested here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, the indexes page will also go here