Order items with the django-admin interface

前端 未结 4 1687
夕颜
夕颜 2021-02-08 14:23

Lets say I have a django model looking like this:

class question(models.Model):
  order = models.IntegerField(\'Position\')
  question = models.CharField(max_len         


        
相关标签:
4条回答
  • 2021-02-08 14:43

    Sure, here is an example of admin.py file with up and down links to change items order: https://github.com/alexvasi/django-simplemenu/blob/master/simplemenu/admin.py

    Basically, you just need to override get_urls method to add your custom views (move_up and move_down in this example).

    More famous example would be django-treemenus, but there is some extra code to support older versions of django.

    0 讨论(0)
  • 2021-02-08 14:47

    Check this: django-orderedmodel.

    This is a really simple implementation of abstract base class for items which can be ordered with admin interface. No external dependencies and easy to use.

    0 讨论(0)
  • 2021-02-08 14:49

    In case someone else is seeking the solution for that issue in 2017, I found the great package Django Admin Sortable

    0 讨论(0)
  • 2021-02-08 15:02

    You can check:

    http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable

    0 讨论(0)
提交回复
热议问题