I am developing a Django app 1.11
, for example i want email should send after user registration, so I decide to use signals for send email, now instead of putting signal handlers and register code in modal file , I created the signals.py
in my app folder ,when i trying to import the signals.py on ready
method in CommonConfig
, but am getting error like follow
django.core.exceptions.ImproperlyConfigured: Cannot import 'common'. Check that 'apps.common.apps.CommonConfig.name' is correct.
My project folder Structure Looks like
/myproject
/myproject
/apps
/common
/configs
/settings
/static
/templates
Installed Apps Looks Like Follow
INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'storages',
'rest_framework',
'apps.common.apps.CommonConfig',]
and my apps\common\apps.py
looks like follow
`
from django.apps import AppConfig
class CommonConfig(AppConfig):
name = "common"
`
What Mistake i made here, how to register the signal with django?
The name
attribute is the full Python path, so in your case it should be "apps.common"
, not "common"
.
class CommonConfig(AppConfig):
name = "apps.common"