You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am migrating a project from django models to django mongoengine documents and I am using django-mongodbforms 0.3 as a replacement for the django forms for models. The migration is seamless so far.
I just tried to update a set of forms constructed from a supplied queryset in this way:
The document class has a unique constraint on a field and the inst.save() raises a NotUniqueError (for that field, if value is unchanged).
I think this happens because the instance is freshly constructed during the is_valid() execution and the id value is not copied to that new instance in construct_instance(), which is called by _post_clean().
In fields_for_document(), any ObjectIdField is skipped. ObjectIdFields are skipped in construct_instance() as well. When I remove
ifisinstance(f, ObjectIdField):
continue
in both functions, the inst.save() succeeds without raising that NotUniqueError.
I think that this is a common use case. Did I do something wrong here?
Best regards,
Chris
The text was updated successfully, but these errors were encountered:
Seriously, did I do something wrong here or have an incorrect understanding of how this should work? If not, I see this as a bug that I'm very wliling to create a pull request for.
First, let me thank you for this nice library.
I am migrating a project from django models to django mongoengine documents and I am using django-mongodbforms 0.3 as a replacement for the django forms for models. The migration is seamless so far.
I just tried to update a set of forms constructed from a supplied queryset in this way:
The document class has a unique constraint on a field and the
inst.save()
raises aNotUniqueError
(for that field, if value is unchanged).I think this happens because the instance is freshly constructed during the
is_valid()
execution and theid
value is not copied to that new instance inconstruct_instance()
, which is called by_post_clean()
.In
fields_for_document()
, anyObjectIdField
is skipped.ObjectIdField
s are skipped inconstruct_instance()
as well. When I removein both functions, the
inst.save()
succeeds without raising thatNotUniqueError
.I think that this is a common use case. Did I do something wrong here?
Best regards,
Chris
The text was updated successfully, but these errors were encountered: