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
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
The text was updated successfully, but these errors were encountered:
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!
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 useAlterSortedManyToManyField
.The problem is that
AlterSortedManyToManyField
does not take into account a custom sort value field name. It only uses the default: operations.py:77For 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 inAlterSortedManyToManyField
The text was updated successfully, but these errors were encountered: