我使用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.7
,django-parler==1.6.5
,django-admin-sortable==2.0.19