From e2027c311246a5259b5495380c67808c71b0bb2a Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Mon, 20 May 2013 17:51:05 +0200 Subject: [PATCH] Improve README example --- README.rst | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 7f25b87..a49a3ad 100644 --- a/README.rst +++ b/README.rst @@ -1,31 +1,29 @@ +.. image:: https://travis-ci.org/vdboor/django_polymorphic.png?branch=master + :target: http://travis-ci.org/vdboor/django_polymorphic + :alt: build-status + Polymorphic Models for Django ============================= Django-polymorphic simplifies using inherited models in Django projects. -When a query is made at the base model, the inherited model classes are returned! +When a query is made at the base model, the inherited model classes are returned. -What is django_polymorphic good for? ------------------------------------- - -Let's take the models ``ArtProject`` and ``ResearchProject`` which inherit -from the model ``Project``, and store them in the database: +When we store models that inherit from a ``Project`` model... >>> Project.objects.create(topic="Department Party") >>> ArtProject.objects.create(topic="Painting with Tim", artist="T. Turner") >>> ResearchProject.objects.create(topic="Swallow Aerodynamics", supervisor="Dr. Winter") -If we want to retrieve all our projects, we do: +...and want to retrieve all our projects, the subclassed models are returned! >>> Project.objects.all() - -Using *django-polymorphic*, we simply get what we stored:: - [ , , ] -Using vanilla Django, we get the base class objects, which is probably not what we wanted:: +Using vanilla Django, we get the base class objects, which is rarely what we wanted: +>>> Project.objects.all() [ , , ]