Tesis 1.0.0
Loading...
Searching...
No Matches
settings.py
Go to the documentation of this file.
1"""
2Django settings for mp_integration project.
3
4Generated by 'django-admin startproject' using Django 5.2.1.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/5.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/5.2/ref/settings/
11"""
12
13import os
14from pathlib import Path
15from dotenv import load_dotenv
16
17# Build paths inside the project like this: BASE_DIR / 'subdir'.
18BASE_DIR = Path(__file__).resolve().parent.parent
19
20# Cargar variables de entorno desde .env si existe
21load_dotenv(os.path.join(BASE_DIR, '.env'))
22
23# SECURITY WARNING: keep the secret key used in production secret!
24SECRET_KEY = os.getenv('DJANGO_SECRET_KEY', 'django-insecure-your-secret-key-for-development')
25
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = os.getenv('DJANGO_DEBUG', 'True') == 'True'
28
29ALLOWED_HOSTS = os.getenv('DJANGO_ALLOWED_HOSTS', '*').split(',')
30
31# Application definition
32INSTALLED_APPS = [
33 'django.contrib.admin',
34 'django.contrib.auth',
35 'django.contrib.contenttypes',
36 'django.contrib.sessions',
37 'django.contrib.messages',
38 'django.contrib.staticfiles',
39 'corsheaders', # Agregado CORS
40 'rest_framework',
41 'payment_service',
42]
43
44MIDDLEWARE = [
45 'django.middleware.security.SecurityMiddleware',
46 'django.contrib.sessions.middleware.SessionMiddleware',
47 'corsheaders.middleware.CorsMiddleware', # Agregado CORS middleware
48 'django.middleware.common.CommonMiddleware',
49 'django.middleware.csrf.CsrfViewMiddleware',
50 'django.contrib.auth.middleware.AuthenticationMiddleware',
51 'django.contrib.messages.middleware.MessageMiddleware',
52 'django.middleware.clickjacking.XFrameOptionsMiddleware',
53]
54
55ROOT_URLCONF = 'mp_integration.urls'
56
57TEMPLATES = [
58 {
59 'BACKEND': 'django.template.backends.django.DjangoTemplates',
60 'DIRS': [],
61 'APP_DIRS': True,
62 'OPTIONS': {
63 'context_processors': [
64 'django.template.context_processors.debug',
65 'django.template.context_processors.request',
66 'django.contrib.auth.context_processors.auth',
67 'django.contrib.messages.context_processors.messages',
68 ],
69 },
70 },
71]
72
73WSGI_APPLICATION = 'mp_integration.wsgi.application'
74
75# Database
76DATABASES = {
77 'default': {
78 'ENGINE': 'django.db.backends.mysql',
79 'NAME': 'railway',
80 'USER': 'root',
81 'PASSWORD': 'BGVqserZKnEpylRlbhwyQcgSmmoocqAt',
82 'HOST': 'shortline.proxy.rlwy.net',
83 'PORT': '45482',
84 'OPTIONS': {
85 'sql_mode': 'traditional',
86 }
87 }
88}
89
90# Password validation
91AUTH_PASSWORD_VALIDATORS = [
92 {
93 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
94 },
95 {
96 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
97 },
98 {
99 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
100 },
101 {
102 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
103 },
104]
105
106# Internationalization
107LANGUAGE_CODE = 'en-us'
108TIME_ZONE = 'UTC'
109USE_I18N = True
110USE_TZ = True
111
112# Static files (CSS, JavaScript, Images)
113STATIC_URL = 'static/'
114
115# Default primary key field type
116DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
117
118# Configuración de Mercado Pago
119MERCADOPAGO_ACCESS_TOKEN = os.getenv('MERCADOPAGO_ACCESS_TOKEN', 'APP_USR-1638397842548868-051022-6da127c22d6d3b0e023d8ae29f3618c2-2435347984')
120
121# URL del backend principal
122MAIN_BACKEND_URL = os.getenv('MAIN_BACKEND_URL', 'https://backmobile1.onrender.com')
123
124# Configuraciones CORS
125CORS_ALLOW_ALL_ORIGINS = True
126CORS_ALLOW_CREDENTIALS = True
127CORS_ALLOW_METHODS = [
128 'DELETE',
129 'GET',
130 'OPTIONS',
131 'PATCH',
132 'POST',
133 'PUT',
134]
135CORS_ALLOW_HEADERS = [
136 'accept',
137 'accept-encoding',
138 'authorization',
139 'content-type',
140 'dnt',
141 'origin',
142 'user-agent',
143 'x-csrftoken',
144 'x-requested-with',
145]