Skip to content

Signal not called #603

@maxthevoice

Description

@maxthevoice

I have an issue since I installed the library. The signals are not called anymore. When creating a User, for example, a Profile instance should be created, but it doesn't.

signals.py:

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        models.Profile.objects.create(user=instance)

tests.py:

class TestCreateUserProfile(TenantTestCase):
    def test_create_user_profile(self):
        user = UserFactory()  # Factory boy
        self.assertIsInstance(user.profile, models.Profile)

settings.py:

SHARED_APPS = (
    'tenant_schemas',
    'dal',
    'dal_select2',

    'django.contrib.contenttypes',

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'django.contrib.postgres',

    'allauth',
    'allauth.account',
    'corsheaders',
    'django_cleanup',
    'django_extensions',
    'debug_toolbar',
    'localized_fields',
    'rest_framework',
    'rest_framework.authtoken',
    'rest_auth',
    'simple_history',
    'versatileimagefield',
    'timezone_field',
    'ordered_model',
    'django_filters',
    'phonenumber_field',
    'djcelery_email',
    'mjml',

    'core',
    'core_project',
    'two_factor_auth',
    'users',
    'controls',
    'occurrences',
    'organizations',
)

TENANT_APPS = (
    'django.contrib.contenttypes',

    'controls',
    'occurrences',
)

INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]

TENANT_MODEL = 'organizations.Organization'

DATABASES = {
    'default': {
        'ENGINE': 'psqlextra.backend',
        'NAME': env.str('POSTGRES_DB'),
        'USER': env.str('POSTGRES_USER'),
        'PASSWORD': env.str('POSTGRES_PASSWORD'),
        'HOST': env.str('POSTGRES_HOST', 'postgres'),
        'PORT': 5432,
    },
}

ORIGINAL_BACKEND = 'django.db.backends.postgresql'
POSTGRES_EXTRA_DB_BACKEND_BASE = 'tenant_schemas.postgresql_backend'

DATABASE_ROUTERS = (
    'tenant_schemas.routers.TenantSyncRouter',
)

I tried with tenant_schemas.postgresql_backend directly as the main ENGINE, but I got the same issue. So I don't think it's related with psqlextra.

I tried it directly from the admin, and I have the same issue.

Let me know if you need more details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions