Order Django Custom Admin

I have a list of images in my administration area. I would like to add an upp / down button for each field. When you click on the field up, the image will be moved in the order of the images. So let's say its number 3 in the list, and I click on it, now it should go to number 2., and also the same for moving down the list order by clicking on the drop-down field, button or image.

Any ideas? Please not that I'm still new to Django

+4
source share
2 answers

This snippet will add up and down links next to each object in the admin lists for this model:

http://www.djangosnippets.org/snippets/998/

I use it in most of my projects. I made a little reusable application out of it, placing it in a separate dictionary (do not forget about the __init__.py file) - # -------- the metaclass inside the models.py file, # -------- the view inside views.py and # -------- the url config inside urls.py

+3
source

You may have to create a model and associate it with images in admin. The administrator is quite extensible, so if you are familiar with object-oriented programming, you should be able to overload some of the admin classes. With that in mind, you should be able to ...

  • Create a model that has an image / image location and weight value.
  • Create a custom admin view that uses this model.

Resources

http://www.djangobook.com/en/1.0/chapter17

http://www.djangobook.com/en/beta/chapter18

0
source

Source: https://habr.com/ru/post/1300059/


All Articles