Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Change the way user uploaded files are handled

Roland Geiderc68071a3e75d
diff --git a/wger/settings.tpl b/wger/settings.tpl
index ca2296bfe..e7f1f662c 100644
--- a/wger/settings.tpl
+++ b/wger/settings.tpl
@@ -41,11 +41,7 @@ BROWSERID_AUDIENCES = [SITE_URL]
# Path to uploaded files
# Absolute filesystem path to the directory that will hold user-uploaded files.
MEDIA_ROOT = {media_folder_path}
-MEDIA_URL = SITE_URL + '/media/'
-if DEBUG:
- # Serve the uploaded files like this only during development
- STATICFILES_DIRS = (MEDIA_ROOT, )
-
+MEDIA_URL = '/media/'
# Allow all hosts to access the application. Change if used in production.
ALLOWED_HOSTS = '*'
diff --git a/wger/urls.py b/wger/urls.py
index 56189b142..5df93110e 100644
--- a/wger/urls.py
+++ b/wger/urls.py
@@ -18,9 +18,10 @@
from tastypie.api import Api
from rest_framework import routers
+from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
-from django.conf.urls.i18n import patterns
+from django.conf.urls.static import static
from django.contrib.sitemaps.views import sitemap
from wger.nutrition.sitemap import NutritionSitemap
@@ -153,7 +154,7 @@ urlpatterns = i18n_patterns(
#
# URLs without language prefix
#
-urlpatterns = urlpatterns + [
+urlpatterns += [
url(r'^robots\.txt$',
TextTemplateView.as_view(template_name="robots.txt"),
name='robots'),
@@ -173,3 +174,9 @@ urlpatterns = urlpatterns + [
name='ingredient-search'),
url(r'^api/v2/', include(router.urls)),
]
+
+#
+# URL for user uploaded files, served like this during development only
+#
+if settings.DEBUG:
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)