Currently, I have been having issues with getting my static and media to work with django on heroku. My static is finally working, but my media won't, and this is my first in any sort of production environment, so I'm not sure if it is done correctly. My media files will work after an upload, however they no longer work once I edit something unrelated and try to push it to heroku typing:
git add .
git commit -m "changes"
git push heroku master
So after I update my heroku app, a user would have to re-add their media files in order for them to work every time I do an update. As far as the code I have so far:
#settings.py
DEBUG = False
MEDIA_ROOT = 'media'
MEDIA_URL = '/media/'
STATIC_ROOT = 'static'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'static',
)
#urls.py
urlpatterns += staticfiles_urlpatterns()
if not settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
I'm pretty lost on what to do, and I have tried several different changes to my urls and settings without any luck. I have read other posts and tried them, I've read the docs, and I still don't really understand unfortunately. Everything was working fine in development, but I had different code for my project in development under my settings. Any help would be greatly appreciated.
EDIT
So after more digging, I decided to give Amazon S3 a try for handling my media files. I'm still not really sure how uploading files to S3 works, but I already created a S3 bucket and set my heroku settings (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET_NAME). I am still unsure of what my media and static settings should look like. If anyone can point me in the right direction, I would really appreciate it.