Reputation: 14317
I would like to run code that will be executed only once in django app.
my structure:
company
project
common
project_config.py
__init__.py
__init__.py:
default_app_config = "company.project.common.ProjectConfig"
settings.py:
..
INSTALLED_APPS = (
"company.project"
)
..
ProjectConfig.py:
from django.apps import AppConfig
class ProjectConfig(AppConfig):
name = "company.project"
def ready(self):
do_something()
I don't see that the method of ready() in my config is being called.
What is wrong?
Upvotes: 2
Views: 3440
Reputation: 527
According to the documentation, you dont need _init_.py
file, just point INSTALLED_APPS up to AppConfig
subclass:
Try this:
INSTALLED_APPS = (
'company.project.common.ProjectConfig',
)
Upvotes: 6