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
Now, what happens is that the categories are inserted and retrieved in the correct order, where as products added to product_items are not.
When I checked the underlying class type of the field p1.categories, it says that its <class 'sortedm2m.fields.create_sorted_many_related_manager..SortedRelatedManager'> where as when I do the same for the reverse relation (product_items) it says <class 'django.db.models.fields.related_descriptors.create_forward_many_to_many_manager..ManyRelatedManager'>
Does this mean that the order is saved explicitly for the field that defines the SortedManyToManyField field and not the related_name/ reverse relation? Do I have to explicitly define the field product_items as a SortedManyToManyField field on the Category model?
I really have been trying to figure this out, but with no lack. I appreciate any help.
The text was updated successfully, but these errors were encountered:
I am using the SortedManyToManyField field from django-sortedm2m as in the following in my models:
Now, lets create and add some data to both the fields:
Now, what happens is that the categories are inserted and retrieved in the correct order, where as products added to product_items are not.
When I checked the underlying class type of the field p1.categories, it says that its <class 'sortedm2m.fields.create_sorted_many_related_manager..SortedRelatedManager'> where as when I do the same for the reverse relation (product_items) it says <class 'django.db.models.fields.related_descriptors.create_forward_many_to_many_manager..ManyRelatedManager'>
Does this mean that the order is saved explicitly for the field that defines the SortedManyToManyField field and not the related_name/ reverse relation? Do I have to explicitly define the field product_items as a SortedManyToManyField field on the Category model?
I really have been trying to figure this out, but with no lack. I appreciate any help.
The text was updated successfully, but these errors were encountered: