让django-admin-sortable和django-parler一起工作

时间:2018-04-16 13:11:20

标签: django python-3.x django-forms django-admin django-parler

我使用through

有两个具有多对多关系的模型
# models.py

class Item(TranslatableModel):
    name = models.CharField(max_length=100)  # this one is translatable

class Person(TranslatableModel):
    name = models.CharField(max_length=100)  # this one is translatable
    items = models.ManyToManyField(
        'Item',
        through='PersonItem',
    )


class PersonItem(Sortable):

    class Meta(Sortable.Meta):
        ordering = ['order']

    person = models.ForeignKey('Person')
    item = SortableForeignKey('Item')

但我无法在管理员

中对Item进行排序
# admin.py

class PersonItemInline(TranslatableTabularInline, SortableTabularInline):
    model = PersonItem
    form = PersonItemForm
    extra = 1

class PersonAdmin(TranslatableAdmin):
    form = PersonForm
    inlines = [
        PersonItemInline
    ]


admin.site.register(Person, PersonAdmin)

当我从translatable继承时,我失去了排序功能。当我尝试继承sortable时,我有以下错误

  

NoReverseMatch使用参数反向'person_person_do_sorting'   找不到'(239,)'和关键字参数'{}'。尝试了0种模式:[]

Env(python 3): django==1.10.7django-parler==1.6.5django-admin-sortable==2.0.19

0 个答案:

没有答案