“Cargar archivos estáticos en django” Código de respuesta

Cómo agregar archivos estáticos en django

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
    BASE_DIR / 'static'
]
Ashamed Anaconda

Cargar archivos estáticos en django

{% load static %}
<img src="{% static 'my_app/example.jpg' %}" alt="My image">
Enthusiastic Emu

Mi plantilla de Django no quiere cargar el archivo estático

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "/static/")

STATICFILES_DIRS = ( 
    STATIC_ROOT,        
)
Cooperative Copperhead

archivos / plantillas de django

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Nyn

Activos estáticos en Django

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
 
 
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
Frail Fowl

Agregar archivo estático en django

STATICFILES_DIRS = [
    BASE_DIR / "static",
    '/var/www/static/',
]
Plain Pheasant

Respuestas similares a “Cargar archivos estáticos en django”

Preguntas similares a “Cargar archivos estáticos en django”

Más respuestas relacionadas con “Cargar archivos estáticos en django” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código