4

I have an app using using Django Nonrel on AppEngine.

I'd like to use a dynamic model similar to WebApp's db.Expando class - is this possible? Is the Expando class exposed to the DNR layer?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • 2
    Option 3 of http://stackoverflow.com/questions/7933596/django-dynamic-model-fields/7934577#7934577 applies to Django-nonrel in general. – Gagandeep Singh Jan 24 '12 at 13:23
  • @GagandeepSingh Thanks. 'from djangotoolbox.fields import DictField' was exactly what I was looking for. If you put that as an answer I'll tick it. – mikemaccana Jan 25 '12 at 10:15

2 Answers2

4

You can use DictField & ListField from djangotoolbox to create dynamic models in Django-nonrel. For e.g.

from djangotoolbox.fields import DictField

class Image(models.Model):
    exif = DictField()

and,

class Post(models.Model):
    words = ListField(models.CharField(max_length=500))
    title = models.CharField(max_length=200)
    content = models.TextField(blank=True)

See Option 3 of Django dynamic model fields for more details.

Community
  • 1
  • 1
Gagandeep Singh
  • 5,755
  • 4
  • 41
  • 60
-1

Django implements its own DB abstraction layer - it's not built on App Engine's db module. If django does not provide it itself, it's not available.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
  • Yes, I'm aware of this. Hence asking 'Is the Expando class exposed to the DNR layer?' in the question. – mikemaccana Jan 25 '12 at 10:12
  • @nailer But that question doesn't make sense in the context: the expando class is not exposed, because it's not used. Django-nonrel does not use the App Engine db framework. It's not possible to expose it, because it's not _there_. – Nick Johnson Jan 25 '12 at 12:34