feat: Video Site App - 4. Display uploaded video

master
Bobson Lin 5 years ago
parent 3df57e2256
commit f276102ad1

@ -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": "PythonDjango",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/video_site/manage.py",
"args": [
"runserver",
// "--noreload"
],
"django": true
}
]
}

@ -7,7 +7,7 @@
<section class="section">
<div class="container">
<video controls>
<source src="earth_video.mp4" type="video/mp4" />
<source src="{{ the_video.video_file.url }}" type="video/mp4" />
</video>
</div>
</section>
@ -19,14 +19,14 @@
<!-- Left side -->
<div class="level-left">
<div class="level-item">
<h1 class="title">Video Title</h1>
<h1 class="title">{{ the_video.title }}</h1>
</div>
</div>
<!-- Right side -->
<div class="level-right">
<p class="level-item">
<strong>11 hours ago</strong>
<strong>{{ the_video.date }}</strong>
</p>
</div>
</nav>

@ -3,5 +3,5 @@ from . import views
urlpatterns = [
path('', views.index, name='index'),
path('video/', views.video, name='video')
path('video/<int:video_id>/', views.video, name='video')
]

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

@ -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/'

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

Loading…
Cancel
Save