scholrly / neo4django

Drop-in Neo4j/Django integration.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inheritance problem with inherited attributes

tonjo opened this issue · comments

Consider the case:

class MyBaseModel(models.NodeModel):
    name=StringProperty(indexed=True)
    class Meta:
         abstract = True

I inherit from MyBaseModel:

class User(MyBaseModel):
    email=StringProperty()

And now:

u=User.objects.create(name='Fail')

TypeError: 'name' is an invalid keyword argument for this function
  File "/home/tonjo/venv/tuned/local/lib/python2.7/site-packages/django/db/models/base.py", line 367, in __init__
  raise TypeError("'%s' is an invalid keyword argument for this function" % kwargs.keys()[0])
TypeError: 'name' is an invalid keyword argument for this function

Not checking base classes?

Anyway it's ok when using:

u=User.objects.create(email='x@y.z') and then
u.name="NoFail"
u.save()

I don't know if it helps, but debugging django.db.models.base.Model.__init__,
which is called when calling .create on NodeModelManager, because of super,
we can see self._meta.fields does not contain any of the superclass field,
causing the error in line 415 of django/db/models/base.py.
In the above example it was probably Django 1.4, that's why it says line 367.

Will it help?