Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance problem with inherited attributes #210

Open
tonjo opened this issue Sep 17, 2013 · 2 comments
Open

Inheritance problem with inherited attributes #210

tonjo opened this issue Sep 17, 2013 · 2 comments

Comments

@tonjo
Copy link
Contributor

tonjo commented Sep 17, 2013

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?

@tonjo
Copy link
Contributor Author

tonjo commented Sep 18, 2013

Anyway it's ok when using:

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

@tonjo
Copy link
Contributor Author

tonjo commented Oct 14, 2013

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant