Static files don't work, event the render doc didn't work

Good day. I have problems with the static files of my Django project. The deployment was successful, but when I go to the page URL, it doesn’t show any images, CSS styles, or JavaScript. I have also followed the steps according to this document: Render Documentation , but it doesn’t solve anything, showing a 500 error instead.

I am using Django 5.0.3 and Python 3.12.3.

Here is my settings.py:

from pathlib import Path

import os

import dj_database_url

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 Deployment checklist | Django documentation | Django

# SECURITY WARNING: keep the secret key used in production secret! 

# SECRET_KEY = ###################################################################################################### 

SECRET_KEY = os.environ.get(“SECRET_KEY”)

# SECURITY WARNING: don't run with debug turned on in production! 

# DEBUG = True 

DEBUG = os.environ.get(“DEBUG”, “False”).lower() == “True”

#ALLOWED_HOSTS = ['192.168.100.6', 'localhost', '127.0.0.1', '172.19.61.234', '192.168.56.1'] 

ALLOWED_HOSTS = os.environ.get(“ALLOWED_HOSTS”).split(" ")

Application definition

INSTALLED_APPS = [

'django.contrib.admin', 

'django.contrib.auth', 

'django.contrib.contenttypes', 

'django.contrib.sessions', 

'django.contrib.messages', 

'django.contrib.staticfiles', 

'goOutApp', 

'crispy_forms',  

'crispy_bootstrap4', 

 

'rest_framework',    

'rest_framework.authtoken', 



'corsheaders', 

'django_filters', 



'django.contrib.sites', 

'allauth', 

'allauth.account', 

'dj_rest_auth.registration', 

]

paso 3: para el registro

SITE_ID = 1

MIDDLEWARE = [

'corsheaders.middleware.CorsMiddleware', 

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

'allauth.account.middleware.AccountMiddleware', 

'corsheaders.middleware.CorsMiddleware', 

]

ROOT_URLCONF = ‘goOut.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', 

            'django.template.context_processors.request', 

            'django.contrib.auth.context_processors.auth', 

            'django.contrib.messages.context_processors.messages', 

        ], 

    }, 

}, 

]

CORS_ALLOW_ALL_ORIGINS = True

WSGI_APPLICATION = ‘goOut.wsgi.application’

DATABASES = {

'default': { 

    'ENGINE': 'django.db.backends.postgresql_psycopg2', 

    'NAME': 'goOut', 

    'USER': 'postgres',        

    'POST': 5432, 

    'HOST': ########################## 

    'PASSWORD': '############ 

} 

}

database_url = os.environ.get(“DATABASE_URL”)

DATABASES[“default”] = dj_database_url.parse(database_url)

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

}, 

]

paso 4: registro e inicio de sesion para este caso desde flutter

para el manejo de auenticacion desde flutter en este caso por medio de un token

REST_FRAMEWORK = {

'DEFAULT_AUTHENTICATION_CLASSES': ( 

    'rest_framework.authentication.TokenAuthentication', 

    'rest_framework.authentication.SessionAuthentication', 

), 

'DEFAULT_PERMISSION_CLASSES': ( 

    'rest_framework.permissions.IsAuthenticated', 

), 

'DEFAULT_FILTER_BACKENDS': ( 

    'django_filters.rest_framework.DjangoFilterBackend', 

), 

}

LANGUAGE_CODE = ‘en-us’

TIME_ZONE = ‘UTC’

USE_I18N = True

USE_TZ = True

#direcotiro para las iamgenes

MEDIA_URL = ‘/imagenes/’

MEDIA_ROOT = os.path.join(BASE_DIR, ‘imagenes’)

STATIC_URL = ‘/static/’

STATIC_ROOT = os.path.join(BASE_DIR, ‘staticfiles’)

STATICFILES_DIRS = (os.path.join(BASE_DIR, ‘static’),)

DEFAULT_AUTO_FIELD = ‘django.db.models.BigAutoField’

CRISPY_ALLOWED_TEMPLATE_PACK=‘bootstrap4’

CRISPY_TEMPLATE_PACK=‘bootstrap4’

LOGIN_REDIRECT_URL = ‘/usuario/’

LOGIN_URL = ‘login’

AUTH_USER_MODEL = ‘goOutApp.CustomUser’

LOGIN_REDIRECT_URL = ‘user_profile’ # Asegúrate de que ‘user_profile’ sea el nombre de una de tus vistas.

LOGOUT_REDIRECT_URL = ‘login’ # Redirige a los usuarios a la página de inicio de sesión después de cerrar sesión.

Please help me

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.