django-typed-models
django-typed-models copied to clipboard
Typedmodel subclass has duplicate fields
trafficstars
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.