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

Typedmodel subclass has duplicate fields #2

Open
hamishcampbell opened this issue Sep 30, 2012 · 0 comments
Open

Typedmodel subclass has duplicate fields #2

hamishcampbell opened this issue Sep 30, 2012 · 0 comments

Comments

@hamishcampbell
Copy link

Possibly a django 1.4 problem.

E.g.

class Animal(TypeModel):
    owner = models.ForeignKey(Owner, related_name="animals")
    name = models.CharField(max_length=40)

class Cat(Animal):
    def speak(self):
        return "Meow"

class Dog(Animal):
    def speak(self):
        return "Woof"

cat = Cat(owner=owner, name='Fluffy')
cat.save()  # missing owner violates key constraints

But constructing with the superclass works:

cat = Animal(type='app.cat', owner=owner. name='Fluffy')
cat.save()  # worked

Seems to be that the class _meta.fields list contains duplicates, so the first time values are popped from kwargs, then removed on the second pass.

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