move the media root and add support for MEDIA_URL

This commit is contained in:
Andreas Zweili 2017-12-31 15:07:22 +01:00
parent 7247681ebb
commit 559f77545d
3 changed files with 10 additions and 2 deletions

3
Vagrantfile vendored
View File

@ -35,6 +35,9 @@ Vagrant.configure("2") do |config|
#Copy the apache configuration for django to the correct place
cp /vagrant/apache/000-default.conf /etc/apache2/sites-available/
mkdir /srv/media
chmod -R 777 /srv/media
#restart the webserver
systemctl restart apache2.service

View File

@ -68,6 +68,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.media'
],
},
},
@ -132,6 +133,8 @@ USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = '/vagrant/django/didgeridoo/static/'
MEDIA_ROOT = '/vagrant/django/didgeridoo/media/'
MEDIA_URL = '/media/'
MEDIA_ROOT = '/srv/media/'
LOGIN_REDIRECT_URL = '/'

View File

@ -15,9 +15,11 @@ Including another URLconf
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'', include('webshop.urls')),
url(r'^admin/', admin.site.urls),
url(r'^admin/', admin.site.urls),
]
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)