开发者

Django admin ManyToManyField: improving usability on change_form?

I have Django models as follows:

class Subject(models.Model):
    name = models.CharField(max_length=35, unique=T开发者_C百科rue)
class Book(models.Model):
    title = models.CharField(max_length=400)    
    subject = models.ManyToManyField(Subject, related_name='books', blank=True, verbose_name="Subject")

There are many Subjects - around 100.

When editing a Book record on the Django admin, it is very difficult to see which subjects are present on a particular book.

The Django admin offers a multi-select list, which is great, but to see for a book, you have to scroll through the entire select list.

It would be much better if either:

  1. I could offer a read-only list of the subjects above the multi-select list, or
  2. the multi-select list began with the selected subjects, then had an entry like '----', then continued with the other subjects.

Does anyone have any idea how I could implement either of the above in Django, to improve the usability of ManyToManyFields in the Django admin?

Thanks!


Use filter_horizontal (or filter_vertical).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜