diff --git a/demoapp/custom_user/models.py b/demoapp/custom_user/models.py index e026f67c..87e5373e 100644 --- a/demoapp/custom_user/models.py +++ b/demoapp/custom_user/models.py @@ -8,4 +8,6 @@ class CustomEmailAddress(AbstractEmailAddress, SwappableMetaMixin): phone_number = models.CharField(max_length=20, blank=True, null=True) class Meta: + app_label = 'sendmail' + db_table = 'custom_email_address' verbose_name = 'Custom User' diff --git a/demoapp/settings.py b/demoapp/settings.py index f9a71b45..ebcc1eb7 100644 --- a/demoapp/settings.py +++ b/demoapp/settings.py @@ -117,7 +117,7 @@ 'NAME': os.getenv('DB_NAME', 'new_post_office'), 'USER': os.getenv('DB_USER', 'post_office'), 'PASSWORD': os.getenv('DB_PASSWORD','post_office'), - 'HOST': os.getenv('DB_HOST','127.0.0.1'), + 'HOST': os.getenv('DB_HOST','localhost'), 'PORT': os.getenv("DB_PORT", '5432'), } @@ -171,38 +171,34 @@ # EMAIL_HOST_PASSWORD = 'test' #print(EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD) -TEMPLATES = [ - { - 'BACKEND': 'sendmail.template.backends.sendmail.SendMailTemplates', - 'APP_DIRS': True, - 'DIRS': [os.path.join(BASE_DIR / 'demoapp' / 'templates')], - 'OPTIONS': { - 'context_processors': [ - 'django.contrib.auth.context_processors.auth', - 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', - 'django.template.context_processors.request', - ] - } - }, - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, +TEMPLATES = [{ + 'BACKEND': 'sendmail.template.backends.sendmail.SendMailTemplates', + 'APP_DIRS': True, + 'DIRS': [os.path.join(BASE_DIR / 'demoapp' / 'templates')], + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.template.context_processors.request', + ] + } +}, { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], }, - -] +}] SENDMAIL = { 'TRACKING_ENABLED': True, @@ -230,7 +226,7 @@ } WSGI_APPLICATION = "demoapp.wsgi.application" #EMAIL_ADDRESS_MODEL = 'sendmail.EmailAddress' -EMAIL_ADDRESS_MODEL = 'custom_user.CustomEmailAddress' +EMAIL_ADDRESS_MODEL = 'sendmail.CustomEmailAddress' DATA_UPLOAD_MAX_NUMBER_FIELDS = 100000 # Database @@ -241,9 +237,7 @@ # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, + {"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",}, {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, @@ -278,7 +272,7 @@ 'JustifyRight', 'JustifyBlock'], ['Link', 'Unlink'], ['Image'], - ['Format'] # Adding headers (e.g., Heading 1, Heading 2, etc.) + ['Format'], # Adding headers (e.g., Heading 1, Heading 2, etc.) ], 'format_tags': 'p;h1;h2;h3;pre', # Define the available formats (headers and others) } diff --git a/sendmail/mixins.py b/sendmail/mixins.py index e520536a..7ba64e0c 100644 --- a/sendmail/mixins.py +++ b/sendmail/mixins.py @@ -8,4 +8,4 @@ def __init_subclass__(cls, **kwargs): if not hasattr(cls, 'Meta'): cls.Meta = type('Meta', (), {}) - cls.Meta.swappable = get_email_address_setting() \ No newline at end of file + cls.Meta.swappable = get_email_address_setting()