Django static files on heroku

后端 未结 5 1522
借酒劲吻你
借酒劲吻你 2020-12-05 05:09

I deployed a django app to heroku, using \"git push heroku master\" which worked absolutely fine.

I then created a second app on the same git using \"heroku create s

5条回答
  •  心在旅途
    2020-12-05 06:10

    Since Django 1.3 you've been able to do the following

    # only showing relevant imports
    from django.conf import settings
    from django.conf.urls.static import static
    
    
    urlpatterns = patterns(
        '',
    
        # your urls go here
    )
    
    if settings.DEBUG:
        urlpatterns += static(settings.STATIC_URL,
                              document_root=settings.STATIC_ROOT)
        urlpatterns += static(settings.MEDIA_URL,
                              document_root=settings.MEDIA_ROOT)
    

提交回复
热议问题