Connect::: frontend react and backend django

34 views
Skip to first unread message

Kani Sbt

unread,
Aug 23, 2023, 5:57:59 AM8/23/23
to Django users
HI sir , 
Please Help me to how to solve this problem , 


this is settings.py :
import os
from pathlib import Path
from datetime import timedelta

BASE_DIR = Path(__file__).resolve().parent.parent


SECRET_KEY = 'django-insecure-ihofv8tmht)!q**8efqqr1t+#(a&a$71s080zs^x*s#w5#sx!4'

DEBUG = True

ALLOWED_HOSTS = ['*']


# Application definition
THIRD_PARTY_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'corsheaders',
    'rest_framework.authtoken',
    'rest_framework_simplejwt.token_blacklist',
    'drf_yasg',
    'import_export', # import and export db data

    'django_crontab', # periodical task trigger
    'dbbackup',  # django-dbbackup
    'django_celery_beat',
    'django_extensions',
    # 'storages',
    # 'gdstorage'
   
   
)

OUR_APPS = (
    'employee',
    'configuration',
    'attendance',
    'audit',
    'master',
)

INSTALLED_APPS = OUR_APPS + THIRD_PARTY_APPS

MIDDLEWARE = [
    'server.middleware.UserIpMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    "corsheaders.middleware.CorsMiddleware",
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'server.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        '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',
            ],
        },
    },
]

# WSGI_APPLICATION = 'server.wsgi.application'
ASGI_APPLICATION = 'server.asgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'sbthrmodule_y0ltln',
         'USER': 'sbthrmodule_mmsv7',
        'PASSWORD': '17mBxjt6sercIAyw',
        'HOST': 'localhost',
        'PORT': '3306',
    },
    'attendance_db': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'skylab',
        'USER': 'admin',
        'PASSWORD': 'kJsgwek8488!ghf^$%',
        'HOST': 'spt-hrm-db.cdhbi944avx7.ap-south-1.rds.amazonaws.com',
        'PORT': '3306',
    },
}


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',
    },
]



LANGUAGE_CODE = 'en-us'

TIME_ZONE =  'UTC'

USE_I18N = True

USE_TZ = True



STATIC_URL = '/static/'
MEDIA_URL = '/media/'
# STATICFILES_DIRS = os.path.join(BASE_DIR, "static"),

if DEBUG:
    STATIC_ROOT = os.path.join(BASE_DIR,'static')
    MEDIA_ROOT =  os.path.join(BASE_DIR, 'media')
else:
    STATIC_ROOT = '/var/www/server/static/'
    MEDIA_ROOT =  '/var/www/server/media/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'configuration.User'

CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = (
    'http://localhost:3000',
    'http://127.0.0.1:3000',
    'https://sbthrmodule.in',
    "https://sbthrmodule.in",
    'http://hrmodule.sbthrmodule.in:8084',
   'http://hrmodule.sbthrmodule.in:8084',
    'http://127.0.0.1:8000',
)
# CORS_ALLOW_CREDENTIALS = True

CSRF_TRUSTED_ORIGINS = ['http://127.0.0.1:8000',"http://localhost:3000",'https://sbthrmodule.in',
    "https://sbthrmodule.in",
    'http://hrmodule.sbthrmodule.in/',
    "http://hrmodule.sbthrmodule.in/","http://127.0.0.1:3000"]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
    ],
    'DEFAULT_RENDERER_CLASSES': [
        "rest_framework.renderers.JSONRenderer",
        "rest_framework.renderers.BrowsableAPIRenderer",
    ],
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 10,
}


SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=30),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
    'ROTATE_REFRESH_TOKENS': True,
    'BLACKLIST_AFTER_ROTATION': True,
    'AUTH_HEADER_TYPES': ('Bearer','Token', ),
    'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken', ),
}

EMAIL_ACTIVE = False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True

# celery settings

CELERY_BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379'
CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'

# redis

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            'hosts': [('127.0.0.1', 6379)],
        },
    }
}

# LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': False,
#     'handlers': {
#         'file': {
#             'level': 'DEBUG',
#             'class': 'logging.FileHandler',
#             'filename': 'logfile.log',
#         },
#     },
#     'loggers': {
#         'django': {
#             'handlers': ['file'],
#             'level': 'DEBUG',
#             'propagate': True,
#         },
#     },
#     'formatters': {
#         'standard': {
#             'format': '%(asctime)s [%(levelname)s] %(name)s [%(filename)s:%(lineno)s] [%(process)d] [%(thread)d] [%(user_ip)s] %(message)s',
#             'datefmt': '%Y-%m-%d %H:%M:%S',
#         },
#     },
# }


# Configure the database backup settings
# DBBACKUP_STORAGE = 'storages.backends.googledrive.GoogleDriveStorage'
# DBBACKUP_GOOGLE_DRIVE_CLIENT_ID = '470509872192-436kvee5qjlj8qht6dgopad7d4lvh4tc.apps.googleusercontent.com'
# DBBACKUP_GOOGLE_DRIVE_CLIENT_SECRET_FILE = 'client.json'
# DBBACKUP_FILENAME_TEMPLATE = '{datetime}.{extension}'

Kani Sbt

unread,
Aug 23, 2023, 5:58:39 AM8/23/23
to Django users
where i connect the domain front end and backend domain 

Kasper Laudrup

unread,
Aug 23, 2023, 6:10:27 AM8/23/23
to django...@googlegroups.com
On 23/08/2023 11.57, Kani Sbt wrote:
> HI sir ,
> Please Help me to how to solve this problem ,
>

You forgot to mention what the problem is. That makes it very hard for
anyone to help you solve it.

Kind regards,
Kasper Laudrup

Kani Sbt

unread,
Aug 23, 2023, 6:14:52 AM8/23/23
to django...@googlegroups.com
sorry sir , the problem is i need to connect the font end to backend , 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/09e8df4d-9d4a-dbf1-4574-47ec9ddfb08e%40stacktrace.dk.

Kani Sbt

unread,
Aug 23, 2023, 6:17:08 AM8/23/23
to Django users
i dont understand that , the front end domain is https://sbthrmodule.in/login  , backend domain is http://hrmodule.sbthrmodule.in/ , but its have the error , but when i run   http://hrmodule.sbthrmodule.in:8085 , when i run python manage.py runserver 0.0.0.0:8085 it will ok , but in main domain not working and i dont know how to solve that problem

Kani Sbt

unread,
Aug 23, 2023, 6:17:10 AM8/23/23
to django...@googlegroups.com
i dont understand that , the front end domain is https://sbthrmodule.in/login  , backend domain is http://hrmodule.sbthrmodule.in/ , but its have the error , but when i run   http://hrmodule.sbthrmodule.in:8085 , when i run python manage.py runserver 0.0.0.0:8085 it will ok , but in main domain not working and i dont know how to solve that problem

Muhammad Juwaini Abdul Rahman

unread,
Aug 23, 2023, 7:50:22 AM8/23/23
to django...@googlegroups.com
Please delete this. You just exposed your DB host, name, and password.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

ivan harold

unread,
Aug 23, 2023, 10:19:20 AM8/23/23
to Django users
Reply all
Reply to author
Forward
0 new messages