【问题标题】:heroku not loading js files in django appheroku 没有在 django 应用程序中加载 js 文件
【发布时间】:2018-06-30 06:07:11
【问题描述】:

我尝试在heroku上部署我的django应用程序,当我打开heroku时它工作正常,但是当我点击按钮或一些字形图标时,它们似乎不起作用。js文件和引导cdn js文件没有被加载.css 文件运行良好,尽管我也尝试了 python manage.py collectstatic。它没有抛出任何错误。

我的 settings.py :

import os
import dj_database_url

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

Requirements.txt:

Django==1.11.6
dj-database-url==0.4.2
django-taggit==0.22.1
gunicorn==19.7.1
Pillow==3.1.2
Markdown==2.6.9
psycopg2==2.7.1
whitenoise==3.3.1

我该如何解决这个问题。谢谢

【问题讨论】:

    标签: javascript python django heroku


    【解决方案1】:

    我通过将 html 文件中包含的引导 CDN 链接中的 http 更改为 https 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-26
      • 2017-09-06
      • 2018-06-16
      • 2021-05-20
      相关资源
      最近更新 更多