Задать вопрос

Тел: +7 965 3737 888

609

Просмотров

4

Ответов

Drag and drop ordering of admin list elements for Grappelli [v2]

Adds drag-and-drop ordering of rows in the admin list view for Grappelli. This is a updated version of Snippet #2306 that works with the current version of Grappelli.

The model needs to have a field holding the position and that field has to be made list_editable in the ModelAdmin. The changes of the ordering are applied after clicking 'Save'.

Вопрос полезен? Да0/Нет0
file_5148.py(4.2Кб)
None

Ответы (4):

Ответakaihola:06.06.2013
Ответ полезен? Да0/Нет0

The regex on line 53 should use the value of the pos_field variable instead of hard-coding "position".

Ответlegnav:14.12.2013
Ответ полезен? Да0/Нет0

Works in Django 1.6 but need to change the definition of MyModelAdmin with something like as follows:

Class MyModelAdmin(admin.ModelAdmin):
#.....
    list_display_links = ('field_1',)
    list_display = ('field_1', 'field_1', ...,  'position',)
    list_editable = ('position',)

Ответmaxsilent:07.04.2013
Ответ полезен? Да0/Нет0

I have some problems with js

Uncaught TypeError: Object [object Object] has no method 'actions' ultralit.loc:56 Uncaught TypeError: Object #[HTML_REMOVED] has no method 'sortable' admin_list_reorder.js:55

What does that mean ?

Ответitsmike:05.04.2013
Ответ полезен? Да0/Нет0

Also works with Django v1.5