To Ogunsanya Opeyemi : my Django app folder is bridge, thus it's OK To [email protected] : I tried but the static files are not found To [email protected] : STATICFILES_DIRS = [BASE_DIR/"<your folder directory>"] is not necessary because it's given already in static_root. Thank you everybody but it does not work yet.
Serge Alard Le jeudi 3 février 2022 à 20:21:30 UTC+1, [email protected] a écrit : > At the bottom of your code, you need to include the STATICFILES_DIRS = > [BASE_DIR/"<your folder directory>"]. > This tells django where your static files are > > On Thu, Feb 3, 2022, 18:49 Opeyemi Ogunsanya <[email protected]> > wrote: > >> Move the static folder to the Django app folder >> >> On Thu, Feb 3, 2022, 6:01 PM Serge Alard <[email protected]> wrote: >> >>> Thank you for the suggestion but it does not work. >>> I add 2 things to make easier your helps : >>> >>> - the settings and wsgi files are in /www/Web_bridge/ Web_bridge/ >>> - the static files are in /www/Web_bridge/static/bridge/ >>> >>> Below an example of connexion.html that calls a static file : >>> >>> {% extends "bridge/sous_base.html" %} >>> >>> {% block content %} >>> {% if error_message %}<p class="erreur">{{ error_message }}</p>{% endif >>> %} >>> <h1>Connexion</h1> >>> <form action="{% url 'bridge:connexion' %}" method="post"> >>> {% csrf_token %} >>> <p> >>> <label>Pseudonyme : </label> >>> <input type="text" name="pseudo" id="pseudo" value="{{ pseudo }}" >>> required /> >>> <br><br> >>> <label for="pass">Mot de passe : </label> >>> <input type="password" name="pass" id="pass" value="{{ mot_de_passe }}"/> >>> <input type="button" id="visible" value="voir" >>> onclick="Afficher(['pass'])" > >>> <br><br> >>> <input type="checkbox" id="oubli" name="oubli" /><label for="oubli">Mot >>> de passe oublié</label> >>> <br><br> >>> </p> >>> <input type="submit" value="Enregistrer"> >>> <input type="button" value="Retour accueil" onclick="location.href='{% >>> url 'bridge:index' %}'"> >>> </form> >>> {% endblock %} >>> >>> {% block script %} >>> {% load static %} >>> {{ block.super }} >>> <script src="{% static 'bridge/password.js' %}"></script> >>> {% endblock %} >>> >>> Thank you in advance for your suggestions. >>> >>> Le jeudi 3 février 2022 à 16:33:10 UTC+1, [email protected] a >>> écrit : >>> >>>> Please add this line below static_url >>>> >>>> STATICFILES_DIRS = [ >>>> 'static' >>>> ] >>>> >>>> On Thu, Feb 3, 2022, 20:53 Serge Alard <[email protected]> wrote: >>>> >>>>> Hello >>>>> >>>>> I developped a project in Django python that works fine. Thus, I >>>>> deployed my project. Everything works but the static files are not found >>>>> by >>>>> the application. >>>>> I give you below the settings and wsgi files. >>>>> >>>>> *WSGI* >>>>> import os >>>>> >>>>> from django.core.wsgi import get_wsgi_application >>>>> >>>>> os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Web_bridge.settings') >>>>> >>>>> application = get_wsgi_application() >>>>> >>>>> *SETTINGS* >>>>> import os >>>>> from pathlib import Path >>>>> >>>>> os.environ['ENV'] = 'PRODUCTION' >>>>> >>>>> BASE_DIR = Path(__file__).resolve(strict=True).parent.parent >>>>> >>>>> DEBUG = False >>>>> SECRET_KEY = >>>>> 'django-insecure-eqlug^3e20v1c5%mo9*mhhea^vv$!$&hyiz-tr%x&6!@6$+e%7' >>>>> ALLOWED_HOSTS = ['*'] >>>>> >>>>> STATIC_ROOT = os.path.join(BASE_DIR, "static") >>>>> >>>>> INSTALLED_APPS = [ >>>>> 'bridge.apps.BridgeConfig', >>>>> 'django.contrib.admin', >>>>> 'django.contrib.auth', >>>>> 'django.contrib.contenttypes', >>>>> 'django.contrib.sessions', >>>>> 'django.contrib.messages', >>>>> 'django.contrib.staticfiles', >>>>> 'django.contrib.sites', >>>>> ] >>>>> >>>>> 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 = 'Web_bridge.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 = 'Web_bridge.wsgi.application' >>>>> >>>>> DATABASES = { >>>>> 'default': { >>>>> 'ENGINE': 'django.db.backends.postgresql', # on utilise l'adaptateur >>>>> postgresql >>>>> 'NAME': 'sudoku_bridge', # le nom de notre base de donnees creee >>>>> precedemment >>>>> 'USER': 'sudoku', # attention : remplacez par votre nom d'utilisateur >>>>> 'PASSWORD': '*', >>>>> 'HOST': 'postgresql-sudoku.alwaysdata.net', >>>>> 'PORT': '5432', >>>>> 'CONN_MAX_AGE': 500, >>>>> } >>>>> } >>>>> >>>>> 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 = 'fr-FR' >>>>> >>>>> TIME_ZONE = 'Europe/Paris' >>>>> >>>>> USE_I18N = True >>>>> >>>>> USE_L10N = True >>>>> >>>>> USE_TZ = False >>>>> >>>>> STATIC_URL = 'static/' >>>>> >>>>> Thank you in advance to help me. >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/django-users/1c8bda14-d16f-405f-9c66-29e63275419bn%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/django-users/1c8bda14-d16f-405f-9c66-29e63275419bn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>> 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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/280871bd-69c4-42a4-b781-578e20c0d7f4n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/280871bd-69c4-42a4-b781-578e20c0d7f4n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> 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 [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CABJxPrG07iMeg-zfoBFFzYnpo9NSX9239YSwbq0-2xYzgKuNfA%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/django-users/CABJxPrG07iMeg-zfoBFFzYnpo9NSX9239YSwbq0-2xYzgKuNfA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e86d1a81-e39b-4f3c-9fab-cdcad26be020n%40googlegroups.com.

