docs
parent
f78b27dc1a
commit
748d10d2d5
4
DOCS.rst
4
DOCS.rst
|
|
@ -37,7 +37,7 @@ All models inheriting from your polymorphic models will be polymorphic as well.
|
||||||
Create some objects
|
Create some objects
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
>>> Project.objects.create(topic="Office Meeting")
|
>>> Project.objects.create(topic="Department Party")
|
||||||
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
>>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner")
|
||||||
>>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
|
>>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter")
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ Get polymorphic query results
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
>>> Project.objects.all()
|
>>> Project.objects.all()
|
||||||
[ <Project: id 1, topic "John's Gathering">,
|
[ <Project: id 1, topic "Department Party">,
|
||||||
<ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
|
<ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
|
||||||
<ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
|
<ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,13 @@ If we want to retrieve all our projects, we do:
|
||||||
|
|
||||||
Using django_polymorphic, we simply get what we stored::
|
Using django_polymorphic, we simply get what we stored::
|
||||||
|
|
||||||
[ <Project: id 1, topic "Weekly Office Meeting">,
|
[ <Project: id 1, topic "Department Party">,
|
||||||
<ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
|
<ArtProject: id 2, topic "Painting with Tim", artist "T. Turner">,
|
||||||
<ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
|
<ResearchProject: id 3, topic "Swallow Aerodynamics", supervisor "Dr. Winter"> ]
|
||||||
|
|
||||||
Using vanilla Django, we get incomplete objects, which is probably not what we wanted::
|
Using vanilla Django, we get incomplete objects, which is probably not what we wanted::
|
||||||
|
|
||||||
[ <Project: id 1, topic "Weekly Office Meeting">,
|
[ <Project: id 1, topic "Department Party">,
|
||||||
<Project: id 2, topic "Painting with Tim">,
|
<Project: id 2, topic "Painting with Tim">,
|
||||||
<Project: id 3, topic "Swallow Aerodynamics"> ]
|
<Project: id 3, topic "Swallow Aerodynamics"> ]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue