from pathlib import Path import os import pytz #print time zones # for x in pytz.all_timezones_set: # print(x) # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.getenv("adminAS_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'allauth', 'allauth.account', 'allauth.socialaccount', 'widget_tweaks', 'Clientes', 'Sistemas', ] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.TokenAuthentication', ], } SITE_ID = 1 MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'Admin.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR,'Templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', # `allauth` needs this from django 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', #custom context processor 'Clientes.saldo_context_proc.get_saldo', ], }, }, ] AUTHENTICATION_BACKENDS = [ # Needed to login by username in Django admin, regardless of `allauth` 'django.contrib.auth.backends.ModelBackend', # `allauth` specific authentication methods, such as login by e-mail 'allauth.account.auth_backends.AuthenticationBackend', ] WSGI_APPLICATION = 'Admin.wsgi.application' ACCOUNT_FORMS = { 'login': 'allauth.account.forms.LoginForm', 'signup': 'allauth.account.forms.SignupForm', 'add_email': 'allauth.account.forms.AddEmailForm', 'change_password': 'allauth.account.forms.ChangePasswordForm', 'set_password': 'allauth.account.forms.SetPasswordForm', 'reset_password': 'allauth.account.forms.ResetPasswordForm', 'reset_password_from_key': 'allauth.account.forms.ResetPasswordKeyForm', 'disconnect': 'allauth.socialaccount.forms.DisconnectForm', } LOGIN_REDIRECT_URL = '/' ACCOUNT_LOGOUT_REDIRECT_URL = '/accounts/login/' ACCOUNT_SIGNUP_REDIRECT_URL =LOGIN_REDIRECT_URL ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE = True EMAIL_TIMEOUT = 10 EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_SUBJECT_PREFIX = 'AS Timbres' if DEBUG : EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'aduanasoftpruebas@gmail.com' EMAIL_HOST_PASSWORD = os.getenv("test_pwd_email") #EMAIL_USE_SSL=False else: EMAIL_USE_TLS = False EMAIL_HOST = 'secure.emailsrvr.com' EMAIL_PORT = 465 EMAIL_HOST_USER = 'noreply@aduanasoft.com.mx' EMAIL_HOST_PASSWORD = os.getenv("pwd_email") EMAIL_USE_SSL=True # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases if DEBUG: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'cfdi_as', 'USER': 'root', 'PASSWORD':os.getenv("BD_PASS"), 'HOST': '127.0.0.1', 'PORT': '', 'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"}, }, } else: DATABASES={ 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'fjrodriguez$cfdi_as', 'USER': 'fjrodriguez', 'PASSWORD':os.getenv("BD_PASS"), 'HOST': 'fjrodriguez.mysql.pythonanywhere-services.com', 'PORT': '3306', 'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"}, } } # Password validation # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { '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', }, ] # Internationalization # https://docs.djangoproject.com/en/4.1/topics/i18n/ LANGUAGE_CODE = 'es-MX' TIME_ZONE = 'America/Chihuahua' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.1/howto/static-files/ if not DEBUG: #STATIC_ROOT = os.path.join(BASE_DIR, "static") STATICFILES_DIRS = [ BASE_DIR / 'static' ] MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' STATIC_URL = '/static/' if DEBUG: STATICFILES_DIRS = [ BASE_DIR / 'static', ] MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' STATIC_URL = '/static/' #STATIC_ROOT = os.path.join(BASE_DIR, "static") # Default primary key field type # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'