Skip to content
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

Incrementing creation_counter breaks field equality #56

Open
mkjpryor-stfc opened this issue Oct 12, 2020 · 0 comments
Open

Incrementing creation_counter breaks field equality #56

mkjpryor-stfc opened this issue Oct 12, 2020 · 0 comments

Comments

@mkjpryor-stfc
Copy link

These lines cannot be used to preserve ordering in forms, because Django's Field.__eq__ uses the creation_counter for equality:

markup_type_field.creation_counter = self.creation_counter + 1
rendered_field.creation_counter = self.creation_counter + 2

Unless the MarkupField is the last field in a model class, this causes a collision of creation_counter with the fields that come after. This breaks the Field equality check and hence any code that relies on field equality. For instance, I came across this bug when using django-concurrency, which relies on field equality to detect the version field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant