python-89 Custom Admin Background Management Framework 1, startup file 2, source code (registration function, create a singleton) 3, design URL

Source: Internet
Author: User

Admin Background Management Framework

Emulate the admin component and develop the stark component

1. startup file

Execute the stark.py file under each app

Rewrite a def ready () function Autodiscover_modules automatically scans all apps under settings for Stark files

def Ready ():
# automatically scan all apps under settings for Stark files Autodiscover_modules ('Stark', Register_to=site)

2. Source code

1. Registration function

  

#Write a registration function classclassStarkmodel (object):#Container Dictionary for the Registry    def __init__(self): Self._registry= {}              #the registration function needs to pass model and configure class object    defRegister (self,model,admin_class=none,**options):#Judging if it's not          if  notAdmin_class:#assign the configuration class to Admin_class withoutAdmin_class = Modelstark#Configuration Class         #Put each configuration class into the registry containerSelf._registry[model] = Admin_class (model)

2. Create a singleton

3.

python-89 Custom Admin Background Management Framework 1, startup file 2, source code (registration function, create a singleton) 3, design URL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.