day73 stark组件启动

一、启动

  django一启动就要执行每一个应用下的stark.py 文件

  配置文件中注册   

    'stark.apps.StarkConfig',

     在StarkConfi类中定义一个ready方法:   

    from django.utils.module_loading import autodiscover_modules
    class StarkConfig(AppConfig):
      name = 'stark'
      def ready(self):
      return autodiscover_modules('stark',)

二、仿写admin的模型表注册

  

 

猜你喜欢

转载自www.cnblogs.com/qingqinxu/p/11282593.html