How to add custom control to django admin site?

Hey, I want to add a custom buttom to the django admin site, and users should be administrators, I don’t expect you to tell me how to do this at every step, but please write a brief correct approach if you can also provide some URLs reading addresses that will be awesome.

+4
source share
2 answers

http://docs.djangoproject.com/en/dev/intro/tutorial02/ - "Customize the administrator form" shows how to change the administration section of the application.

http://docs.djangoproject.com/en/dev/topics/auth/ - "get_group_permissions ()" will allow you to obtain group user rights. "has_perm ()" returns true for one permission.

http://docs.djangoproject.com/en/dev/howto/custom-management-commands/ - how to configure django management

http://docs.djangoproject.com/en/dev/ref/contrib/admin/ - "ModelAdmin" can be used to specify a template for the admin site

Using them, you can create your own template with any custom controls and show them only if the user has a specific permission.

+4
source

You can copy the file django / django / contrib / admin / templates / admin / base.html (or base_site.html) into your project /templates/admin/base.html and then set up base.html

This part is {% block footer %}<div id="footer"></div>{% endblock %}

Also this template world can help {% if user.is_active and user.is_staff %}

+3
source

All Articles