[Django]-Model inheritance in django-nonrel on app engine

0👍

You can use ListField in djangotoolbox, it will extend django-nonrel with new type field ListField, it’s just like a one-to-many type field in Django, that you can save all child entities in the field with ListProperty.

There’s a useful documentation on how-to ListField: http://django-mongodb-engine.readthedocs.org/en/latest/topics/lists-and-dicts.html

Model

from djangotoolbox.fields import ListField

class Post(models.Model):
    ...
    tags = ListField()

Usage

>>> Post(tags=['django', 'mongodb'], ...).save()
>>> Post.objecs.get(...).tags
['django', 'mongodb']

Notice

For capability, you better save id instead of foreign key because you’re saving different types objects into one ListField field. And better re-implement __del__ function to make sure the deletion will work well.

Leave a comment