add support for media upload

parent ddcac344
...@@ -10,7 +10,7 @@ For the full list of settings and their values, see ...@@ -10,7 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
from os import getenv from os import getenv, path
from pathlib import Path from pathlib import Path
from dotenv import load_dotenv from dotenv import load_dotenv
...@@ -19,6 +19,8 @@ load_dotenv() ...@@ -19,6 +19,8 @@ load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
MEDIA_ROOT = path.join(BASE_DIR, 'media')
MEDIA_URL = '/uploads/'
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
......
...@@ -13,6 +13,8 @@ Including another URLconf ...@@ -13,6 +13,8 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
import Announcements.views as Announcements_views import Announcements.views as Announcements_views
...@@ -34,3 +36,6 @@ urlpatterns = [ ...@@ -34,3 +36,6 @@ urlpatterns = [
] ]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment