-
Notifications
You must be signed in to change notification settings - Fork 90
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
admin breaks if a moderated model was changed (migration) #112
Comments
Was the model definition changed to have an extra field that didn't exist when the object was moderated? If so, this is already taken care of, as evidenced by the tests I wrote. |
It breaks when a serialized field doesn't exist in the new model. For example, MyModel(a:FloatField, b:FloatField) is serialized to s. A migration is done, and now MyModel's definition is MyModel(a:FloatField, c:CharField). You cannot deserialize s into MyModel's definition because b doesn't exist anymore. |
@Moustacha Hi, got some news on this bug ? |
Are you able to provide a sample project that hits this bug? |
A sample project ? That would be hard. However, there are steps to reproduce:
|
I tried making a basic project (https://github.com/Moustacha/django-moderation-issue112) that re-creates those steps, and I'm still not hitting any bugs. I created a model with two fields, a & b. Moderated it, and created a couple of moderations for an instance. Then i removed field b and added c. Viewing the current object doesn't result in any errors: |
I had this issue here too. After one field was renamed in model. @Moustacha Viewing the object works, but if you try to save it, you get the exception! |
The workarround was to erase all ModeratedObjects:
|
Here my traceback:
|
This also happens when you change a field definition such that previous data is invalid. Example: # models.py
class Example(models.Model):
field = models.NullBooleanField(null=True, blank=True)
# moderator.py
class ExampleModerator(GenericModerator):
pass
moderation.register(Example, ExampleModerator) Then create a new # models.py
class Example(models.Model):
field = models.BooleanField(default=False)
|
Having same issue. I recognized if you approve your object before saving it, the process will work correctly... but this "work-around" is a problem because then rejected or re-edited objects get approved automatically... |
Having the same issue with Django 2.2. There was a solution for this bug? |
there is a problem in django-moderation which prevents its use in production: the deserialization methods raise an error if a model instance was saved for moderation, then restored after the model definition was changed.
You simply get an error stating that a field does not exist.
Is this possible to fix this so that non existent fields don't raise an error ?
The text was updated successfully, but these errors were encountered: