Change the way user uploaded files are handled

This commit is contained in:
Roland Geider
2016-09-18 11:46:34 +02:00
parent 849fba1754
commit c68071a3e7
2 changed files with 10 additions and 7 deletions

View File

@@ -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 = '*'

View File

@@ -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)