Closed bradrice closed 2 years ago
Are you talking about the list view of a model, or the inlined list view of a model's detail view?
In a list view of a model
from django.contrib import admin
from .models import Artwork, Category
from adminsortable2.admin import SortableAdminMixin
class ArtworkAdmin(SortableAdminMixin, admin.ModelAdmin):
js = ('js/form.js',)
list_display = ('title','weightedOrder', 'forSale', 'sold', 'media', 'price')
readonly_fields = ('imgheight', 'imgwidth')
admin.site.register(Artwork, ArtworkAdmin)
And my model has:
weightedOrder = models.IntegerField(default=0, blank=False, null=False)
a screen capture:
https://www.dropbox.com/s/hh3x7jazhpxntfa/simplescreenrecorder-2022-01-02_10.24.07.mp4?dl=0
django-admin-sortable2 saves the order of the items immediately after they have been dragged.
If this doesn't work for you, check that weightedOrder
has been initialized, ie. all entries must have different values. Use the management command if required. If it still doesn't work, check your browser dev console.
I had been using weigthedOrder previously and had been typing values in. Perhaps that is the issue. The docs said I could use a previously used field, so I didn’t realize that was a problem to have similar values.
On Sun, Jan 2, 2022 at 1:20 PM Jacob Rief @.***> wrote:
django-admin-sortable2 saves the order of the items immediately after they have been dragged. If this doesn't work for you, check that weightedOrder has been initialized, ie. all entries must have different values. Use the management command if required. If it still doesn't work, check your browser dev console.
— Reply to this email directly, view it on GitHub https://github.com/jrief/django-admin-sortable2/issues/296#issuecomment-1003755418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACCPYDOOCKA646VEBIOUZDUUCJNRANCNFSM5LCZG2OA . You are receiving this because you authored the thread.Message ID: @.***>
-- Brad Rice @.***
please close this issue
I tried creating a new field for order and use it as the ordering field. It still won't sort and save.
I tried creating a new field for order and use it as the ordering field.
Did you initialize it?
Anyway, you certainly made a configuration error. This library is used by thousands of projects without complains.
When you say initialize it, you mean migrate it, correct?
On Wed, Jan 5, 2022 at 2:46 AM Jacob Rief @.***> wrote:
I tried creating a new field for order and use it as the ordering field.
Did you initialize it?
Anyway, you certainly made a configuration error. This library is used by thousands of projects without complains.
— Reply to this email directly, view it on GitHub https://github.com/jrief/django-admin-sortable2/issues/296#issuecomment-1005453165, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACCPYH2TALXKDQXCVHRTYDUUPZNXANCNFSM5LCZG2OA . You are receiving this because you authored the thread.Message ID: @.***>
-- Brad Rice @.***
Sorry, I didn't get around to closing this, but yes, it was a matter of initializing the data. I got the reorder tool to work on my model and then it started working. Thank you @jrief
I can sort using the drag handles in my list. The items sort, but when I reload the page, the items go back into the previous sort order. How does the module save the sorted items?