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

Prevent Django ManyToManyField from being imported through sortedm2m #93

Merged

Conversation

daynemay
Copy link
Contributor

@daynemay daynemay commented Nov 24, 2016

At my workplace, we recently uncovered a bug (in our codebase) where we had defined a field in models.py as a SortedManyToManyField but created it in the migration as a ManyToManyField (i.e. an unsorted django.db.models.fields.related.ManyToManyField), which was inadvertently imported through sortedm2m with the following statement:

from sortedm2m.fields import ManyToManyField

The author clearly meant to use a SortedManyToManyField in the migration - since that would match the model field, and they were importing from sortedm2m - but through IDE autocomplete or simple human error, they imported the ManyToManyField.

This small change would prevent others making the same error.

@gregmuellegger
Copy link
Collaborator

Sweet catch and very nice that you thought of giving this back to the community! Thanks for your efforts here.

@gregmuellegger gregmuellegger merged commit 6be950d into jazzband:master Jan 3, 2017
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

Successfully merging this pull request may close these issues.

2 participants