django
Save with update_fields did not affect any rows (while changing class)
Let's have a model with decorator: def upgradable(model): #classmethod def upgrade(cls, base, **kwargs): base.__class__ = cls for attr, value in kwargs.items(): setattr(base, attr, value) return base setattr(model, "upgrade", upgrade) return model class Person(models.Model): name = models.CharField(max_length=50) def save(self, *args, **kwargs): self.name = self.name.upper() super(Person, self).save(*args, **kwargs) and inherited model: #upgradable class User(Person): email = models.EmailField(); and I'm trying to upgrade person = Person.objects.get(...) user = User.upgrade(person, email="example#example.com") user.save() But the error appears: Save with update_fields did not affect any rows. in connection to super(Person, self).save(*args, **kwargs) (in method save of model person) It isn't total wrong, because indeed I don't want to change anything in table person, I just want to add something to table user (pointer to person and email). So how to skip this warning?
The answer wasn't obvious - I tried to add user.save(force_update = True) but it isn't work. But user.save(force_insert = True) do the job. Strange, but works.
Related Links
Form Wizard: error undefined variables
Sync Fabric with South
“No module named balanced_django.middleware”
Django Invalid Form, Keeping the Next Parameter
How to link to an .ipa file (over the air ios app installation) using django and STATIC_URL?
Pulling out a product only once from a django view
How to translate a message/variable in Django templates?
Getting the selected value on a Django forms.ChoiceField
django dynamic data driven form fields [duplicate]
django best practice query foreign key
Sphinx documentation of django tests
Django resize image during upload [closed]
object has no attribute 'result_count'
Django 1.5 NoReverseMatch at /blog/
django-social-auth backend not found
Django: save model object of a ModelForm