现在settings.py中,如下插入的最后3行

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app01.apps.App01Config',
    'app02.apps.App02Config',
    'stark.apps.StarkConfig',
]

 

 

apps.py的文件,记得提前在settings中insert中加入app名称

1 from django.apps import AppConfig
2 from django.utils.module_loading import autodiscover_modules
3 
4 class StarkConfig(AppConfig):
5     name = 'stark'
6 
7     def ready(self):
8         autodiscover_modules('stark')

 

在各个app文加下加入stark.py文件,写入想要实现某种功能的代码

 

相关文章:

  • 2021-12-01
  • 2022-01-05
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-11-04
  • 2021-05-20
  • 2021-11-30
相关资源
相似解决方案