Tengo un proyecto en el que mi socio trabajó en la interfaz sin usar ningún marco, solo usó js, html y css. Quería adjuntar ese frente a la parte posterior usando Django.
Aquí están las configuraciones de settting.py
STATIC_ROOT = os.path.join('C:/Users/1224095/work/Backend/backend/static') STATIC_URL = '/static/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) Agregué {% carga estática%} en mi encabezado html. Para no confundirlo, creé un directorio estático llamado static, y dentro obtuve mis activos y complementos de la interfaz, además, en cada lugar, agregué href= {% static 'path to the file' %} .
Como resultado, recibo un error de 404, ¿alguien tiene una idea de por qué? aquí hay un ejemplo de mi html:
<!doctype html> <html lang="en"> {% load static %} <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="{% static 'assets/plugins/simplebar/css/simplebar.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/metismenu/css/metisMenu.min.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/vectormap/jquery-jvectormap-2.0.2.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/highcharts/css/highcharts-white.css' %}" rel="stylesheet" />(1): solo puede usar esto en su configuración.py -> STATIC_URL = '/static/'
(2): Tienes que copiar y pegar tus archivos estáticos (JavaScript, CSS, etc) en tus templates .
Se verá así:
App |_migrations |_templates |_static |__App (directory with the App name) |_assets |_js |_css |_img |_plugins |_....Tu HTML debería verse así:
<!doctype html> <html lang="en"> {% load static %} <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="{% static 'App/assets/plugins/simplebar/css/simplebar.css' %}" rel="stylesheet" />Simplemente no olvide escribir Aplicación antes de cada 'activo'