0
我幾乎把我的django項目部署到heroku,但是我的靜態文件沒有顯示出來。Django靜態文件在Heroku上不顯示
|--- .git
|--- .gitignore
|--- Procfile
|--- requirements.txt
|--- manage.py
|--- myproj
|--- __init__.py
|--- settings.py
|--- urls.py
|--- wsgi.py
|--- templates
|--- *.html
|--- static
|--- media
|--- static
|--- js
|--- *.js
|--- css
|--- *.css
|--- static-only
|--- myapp
當我在本地運行我的項目,我所有的靜態文件,退出代碼爲200
然而,部署到Heroku的時候都不會位於訪問。 collectstatic是成功的。
下面是我的settings.py
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'
MEDIA_ROOT = 'media'
# Template location
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "templates"),
)
STATICFILES_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "static"),
)
相關的部分有沒有人見過這個?
編輯
myproj/urls.py
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
import settings
urlpatterns = (
url(r'^$', 'myapp.views.home', name='home'),
url(r'^admin/', include(admin.site.urls)),
url(r'^auth/$', 'myapp.views.auth_view'),
url(r'^logout/$', 'myapp.views.logout'),
url(r'^loggedin/$', 'myapp.views.loggedin'),
url(r'invalid/$', 'myapp.views.invalid_login'),
url(r'^register/', 'myapp.views.register_user'),
url(r'^register_success/', 'myapp.views.register_success'),
url(r'^files/', 'myapp.views.files'),
url(r'^practice/', 'myapp.views.practice'),
url(r'^download/', 'myapp.views.download'),
url(r'^listening/', 'myapp.views.listening'),
url(r'^training/', 'myapp.views.training'),
url(r'^upload/', 'myapp.views.upload'),
url(r'^update_user/', 'myapp.views.update_user'),
)
什麼是'DEBUG'設置的一端固定呢?你是否按照[在Heroku上部署的說明](https://devcenter.heroku.com/articles/django-assets)? –
我嘗試了'DEBUG = True'和'DEBUG = False'。我遵循這一點,但沒有奏效。 – erip
發佈您的urls.py –