Y
Y
Yura Khlyan2018-06-22 15:57:24
PostgreSQL
Yura Khlyan, 2018-06-22 15:57:24

Django doesn't start signal. Or is that how it should be?

Good day.
I have two Django projects ( VetpharmCommerce and VetDirectory ) on different databases, but they share a common table Users. Done like this:

DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'vet-directory',
    'USER': 'vetpharm',
    'PASSWORD': '',
    'HOST': '127.0.0.1',
    'PORT': '',
    'TEST': {
      'ENGINE': 'django.db.backends.sqlite3',
    }
  },
  'users': {
    'ENGINE': "django.db.backends.postgresql_psycopg2",
    'NAME': "vetpharm_commerce",
    'USER': "vetpharm",
    'PASSWORD': "",
    'HOST': "127.0.0.1",
    'PORT': "5432"
  }
}

VetpharmCommerce has a logic for creating a profile Userwith a signal:
def create_profile(sender, instance, created, **kwargs):
    """ Creates profile for user """
    CustomerProfile.objects.get_or_create(user=instance)

post_save.connect(create_profile, sender=compat.AUTH_USER_MODEL)

When I register Userwith VetpharmCommerce , then everything is OK, CustomerProfileit is created, but if I Userregister with VetDirectory , then the record Useris created, but CustomerProfilenot.
Here's my question: how to make it so that it would be CustomerProfilecreated regardless of which site you registered on? Can I get by with one signal on VetpharmCommerce , or does VetDirectory also need the same signal?
I will be very grateful for your help.
PS Sorry for the bad Russian.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question