Hi Euan,
Impressive work.
On Tue, Jan 25, 2011 at 5:13 PM, Euan Goddard <[email protected]>wrote:
> Hi,
>
> I've recently been working on an open source project to augment the
> inheritance of models in Django. This project, called "djeneralize"
> allows you to declare specializations on your models and then query
> the general case model and get back the specialized instances. A
> simple example of the models might be:
>
> class Fruit(BaseGeneralizedModel):
> name = models.CharField(max_length=30)
>
> def __unicode__(self):
> return self.name
>
> class Apple(Fruit):
> radius = models.IntegerField()
>
> class Meta:
> specialization = 'apple'
>
> class Banana(Fruit):
> curvature = models.DecimalField(max_digits=3, decimal_places=2)
>
> class Meta:
> specialization = 'banana'
>
> class Clementine(Fruit):
> pips = models.BooleanField(default=True)
>
> class Meta:
> specialization = 'clementine'
>
> which then allows the following queries to be executed:
>
> >>> Fruit.objects.all() # what we've got at the moment
> [<Fruit: Rosy apple>, <Fruit: Bendy banana>, <Fruit: Sweet
> clementine>]
> >>> Fruit.specializations.all() # the new stuff!
> [<Apple: Rosy apple>, <Banana: Bendy banana>, <Clementine: Sweet
> clementine>]
>
> I hope this type of general case/specialization might be of some use
> to someone else out there. We're planning on integrating this work in
> a large project we're undertaking on content categorization.
>
> Grab the source at github: https://github.com/2degrees/djeneralize
>
> or you can easy_install it (easy_install djeneralize).
>
> Feedback, etc. very welcome.
>
> Thanks, Euan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
--
Thanks & Regards
*Manoj Kumar*
*
*
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.