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

Problem with AlterSortedManyToManyField or the documentation about it #87

Closed
jannon opened this issue Jul 31, 2016 · 2 comments
Closed

Comments

@jannon
Copy link

jannon commented Jul 31, 2016

Hi, so I just found django-sortedm2m and am stoked about it, but I ran into a little problem integrating it. The problem is a little similar to #60 so hopefully I'll shed a little light on what might be going on

I have an two existing models with a many-to-many relationship with a custom through-table. That table already has an 'order' field. As such, as per the Readme on github, I used the sort_value_field_name. I also followed the Readme and modified the created migration to use AlterSortedManyToManyField.

The problem is that AlterSortedManyToManyField does not take into account a custom sort value field name. It only uses the default: operations.py:77

For my situation, the solution was simple. Just don't use the operation and everything else else just works great! But I think maybe either the operation should take into account a sort_value_field_name set on the field or, more simply, the documentation should just highlight that if you have an existing field and through table, don't change the migration.

Thanks the package

EDIT: oh, I also had to add _sort_field_name = 'order' to my through model, so maybe it should be addressed in AlterSortedManyToManyField

@gregmuellegger
Copy link
Collaborator

Oh absolutely! Thanks for pointing this out, I haven't come across this yet. I agree that we should handle this in the AlterSortedManyToManyField operation, if possible. Otherwise a simple hint in the README should do it.

Are you interested in giving it a shot with a pull request? Any help here is much appreciated!

@gregmuellegger
Copy link
Collaborator

Support for it is now part of the 1.5.0 release https://pypi.python.org/pypi/django-sortedm2m

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

2 participants