Xadmin learning notes (2) -- modifying Django tutorial instances (1), xadmindjango
Preface
Xadmin is a management framework based on Python and Django. to be proficient in using it, it is necessary to learn Django. In the process of learning Django, you may want to use xadmin to verify the new effect. This article is based on the official Django documentation.TutorialDuring the process of exploration.
FAQ 1: How to modify xadmin's site-title and site-footer?
Site-titleand site-footerare both set on the base_site.html template page and can be found in the xadmin \ templates \ xadmin directory under the xadmin installation directory.
It can be seen from the picture that both site_title and site_footer can be set through the program. How can we set these two variables? Add the GlobalSetting class to the adminx. py file. The specific code is as follows:
1 class GlobalSetting (object): 2 sets Title3 site_title = 'my title' 4 sets Footer5 site_footer = 'my Footer '6 xadmin. site. register (views. CommAdminView, GlobalSetting)
After inserting this code, we modified site-title and site-footer. View the modified effect:
FAQ 2: how to modify the menu settings of xadmin?
By default, xadmin provides a set of menu setting rules for storage using the SortedDict type. The SortedDict sorting order is maintained in the insert order in Django official documents, therefore, the menu display and adminx. the order of registration in the py file is related. You can change the display order of the menu by adjusting the registration order.
However, this step alone does not meet our requirements. We hope to be able to change the menu title, icon, control menu permissions, and even menu routes as needed, then we can use the following settings to modify.
1 class GlobalSetting (object): 2 # menu setting 3 def get_site_menu (self): 4 return (5 {'title': 'Vote management', 'perm': self. get_model_perm (Poll, 'change'), 'menus' :( 6 {'title': 'Voting ', 'url': self. get_model_url (Poll, 'angelist')}, 7 {'title': 'ballot ', 'url': self. get_model_url (Choice, 'angelist')} 8)}, 9) 10 xadmin. site. register (views. commAdminView, GlobalSetting)
The setting is still performed in the adminx. py file. After the setting, the following menu is displayed.
For more details about menu settings, refer to the FAQ in the xadmin official document: How to customize the system menu.
PS: Today, I learned a lot through my own exploration and viewing the Django official documentation and xadmin official documentation. I am very happy that I have helped my friends solve the problem and felt that learning is very valuable. If you have no Django Foundation and want to learn xadmin like me, you can read the Django document, use xadmin to implement it, and then view the code in xadmin. Although it feels hard, you will gain some benefits, the difference between xadmin and the built-in admin is also known.
How can I change the admin template of django161?
Is the directory address set in setting? TEMPLATE_DIRS = [OS. path. join (BASE_DIR, 'templates')]
Convert equation ﹙ x + 2 ﹚ ﹙ 1-3x cost = 2x to the normal form -- quadratic coefficient is -- one term is -- constant term is --
Solution:
(X + 2) (1-3x) = 2x
X-3x 2 + 2-6x = 2x
3x + 7x-2 = 0
So
The general format is 3x + 7x-2 = 0
The quadratic coefficient is 3.
One item is 7x
Constant is-2