Maison  >  Questions et réponses  >  le corps du texte

python - Django自定义模板标签和过滤器

通过官方手册来自定义了过滤器,自定义过滤器可以使用,但是发现自带的static 无法使用,js,css等没办法加载

阿神阿神2728 Il y a quelques jours652

répondre à tous(1)je répondrai

  • 高洛峰

    高洛峰2017-04-18 09:34:41

    La statique est un problème distinct
    Prenons http://192.168.0.27:8000/stat... comme exemple
    Chemin du projet (le dossier où se trouve manage.py) : c:/test/
    chemin de l'application : c:/test/app/

    1. Ajoutez : STATIC_URL = '/static/' dans le paramètre
    C'est-à-dire appeler directement le fichier statique dans le chemin de l'application, tel que : c:/test/app/static/bootstrap.min.css.

    2. Ajoutez le paramètre : STATIC_ROOT = os.path.join(BASE_DIR,'static')
    Vous devez exécuter python manage.py collectstatic
    sous le chemin c:/test/, puis appeler c :/test/static/bootstrap.min.css fichier

    répondre
    0
  • Annulerrépondre