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
enum.EnumField seems not to work in Django 1.10 #39
Comments
I have the exactly same issue. Creating and saving an instance of a model with an EnumField leads to ValueError("Cannot force an update in save() with no primary key."). |
This is blocking some application upgrades. Might have something to do with this warning you get using django-enumfield 1.3b2 in django 1.9.x: |
I just found PR #37 which discusses this in more detail... |
I have a similar problem using Django 1.10.2 and django-enumfield 1.2.1:
|
This is similar to this issue jpwatts/django-positions#49 def get_deferred_fields(self):
enum_fields = filter(lambda x: isinstance(x, enum.EnumField), ThisModel._meta.fields)
enum_field_names = set(funcy.pluck_attr('name', enum_fields))
deferred_set = super(ThisModel, self).get_deferred_fields()
return {f for f in deferred_set if f not in enum_field_names} |
Bartvds, I at last ended on using this branch https://github.com/i2biz/django-enumfield/tree/jbzdak/django110. It works ok with django 1.10. Only thing that I lost was validating transitions, but I managed to rewrite it myself as standalone function. |
@Bartvds Hi, we just need a project where we could continue to develop the package. Currently I am working with 1.10 one and soon will need to do something about enumfield. Preliminary plan is to merge |
@georgekpg Hi, can you please explain how did you manage to rewrite validating transitions, I'm currently having the same issue. |
@sinarz, my implementation is based upon django-simple-history, it helps me to detect changed fields.
And I can call this in clean method implementation of my model
|
Thanks @georgekpg , nice implementation. I'll give it a try. |
#43 works for me as a drop-in replacement in Django 1.11, original patch was from @kjagiello |
Please try version 1.4rc1 |
1.4 has been released. Please reopen if it doesn't work for any reason |
In django 1.10 get_deferred_fields routine from django.db.models.base counts all enum.EnumField fields in a model as deferred fields. As a result it passes update_fields in save_base routine and raises "Cannot force an update in save() with no primary key" exception when I attempt to save new model instance.
In django 1.9.9 the same model works okay. I am using django-enumfield==1.3b2 installed with pip
The text was updated successfully, but these errors were encountered: