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