diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..12c573f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python:Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/video_site/manage.py", + "args": [ + "runserver", + // "--noreload" + ], + "django": true + } + ] +} \ No newline at end of file diff --git a/video_site/core/templates/core/video.html b/video_site/core/templates/core/video.html index f08e4bc..7b320e9 100644 --- a/video_site/core/templates/core/video.html +++ b/video_site/core/templates/core/video.html @@ -7,7 +7,7 @@
@@ -19,14 +19,14 @@
-

Video Title

+

{{ the_video.title }}

- 11 hours ago + {{ the_video.date }}

diff --git a/video_site/core/urls.py b/video_site/core/urls.py index 4c5ef05..11c5d2d 100644 --- a/video_site/core/urls.py +++ b/video_site/core/urls.py @@ -3,5 +3,5 @@ from . import views urlpatterns = [ path('', views.index, name='index'), - path('video/', views.video, name='video') + path('video//', views.video, name='video') ] diff --git a/video_site/core/views.py b/video_site/core/views.py index f2aa007..6e92812 100644 --- a/video_site/core/views.py +++ b/video_site/core/views.py @@ -1,9 +1,12 @@ from django.shortcuts import render +from .models import Video def index(request): return render(request, 'core/index.html') -def video(request): - return render(request, 'core/video.html') +def video(request, video_id): + the_video = Video.objects.get(pk=video_id) + context = {'the_video': the_video} + return render(request, 'core/video.html', context) diff --git a/video_site/video_site/settings.py b/video_site/video_site/settings.py index a32d001..1b518c4 100644 --- a/video_site/video_site/settings.py +++ b/video_site/video_site/settings.py @@ -119,3 +119,6 @@ USE_TZ = True # https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' + +MEDIA_ROOT = BASE_DIR +MEDIA_URL = '/media/' diff --git a/video_site/video_site/urls.py b/video_site/video_site/urls.py index ced6d91..24a09cd 100644 --- a/video_site/video_site/urls.py +++ b/video_site/video_site/urls.py @@ -15,8 +15,10 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.conf import settings +from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('', include('core.urls')) -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)