From bf0785bc78820df47d8ad74483f35a6ad734f2aa Mon Sep 17 00:00:00 2001 From: Chneemann Date: Sun, 11 Aug 2024 09:05:13 +0200 Subject: [PATCH] upload videos in the backend --- backend/videoflix/content/__init__.py | 0 backend/videoflix/content/admin.py | 4 ++++ backend/videoflix/content/apps.py | 6 ++++++ backend/videoflix/content/migrations/__init__.py | 0 backend/videoflix/content/models.py | 11 +++++++++++ backend/videoflix/content/tests.py | 3 +++ backend/videoflix/content/views.py | 3 +++ backend/videoflix/videoflix/settings.py | 4 ++++ backend/videoflix/videoflix/urls.py | 7 ++++--- 9 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 backend/videoflix/content/__init__.py create mode 100644 backend/videoflix/content/admin.py create mode 100644 backend/videoflix/content/apps.py create mode 100644 backend/videoflix/content/migrations/__init__.py create mode 100644 backend/videoflix/content/models.py create mode 100644 backend/videoflix/content/tests.py create mode 100644 backend/videoflix/content/views.py diff --git a/backend/videoflix/content/__init__.py b/backend/videoflix/content/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/videoflix/content/admin.py b/backend/videoflix/content/admin.py new file mode 100644 index 0000000..b7e2741 --- /dev/null +++ b/backend/videoflix/content/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Video + +admin.site.register(Video) \ No newline at end of file diff --git a/backend/videoflix/content/apps.py b/backend/videoflix/content/apps.py new file mode 100644 index 0000000..273d169 --- /dev/null +++ b/backend/videoflix/content/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ContentConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'content' diff --git a/backend/videoflix/content/migrations/__init__.py b/backend/videoflix/content/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/videoflix/content/models.py b/backend/videoflix/content/models.py new file mode 100644 index 0000000..633fa76 --- /dev/null +++ b/backend/videoflix/content/models.py @@ -0,0 +1,11 @@ +from django.db import models +from datetime import date + +class Video(models.Model): + created_at = models.DateField(default=date.today) + title = models.CharField(max_length=80) + description = models.CharField(max_length=500) + video_file = models.FileField(upload_to='videos', blank=True, null=True) + + def __str__(self): + return self.title \ No newline at end of file diff --git a/backend/videoflix/content/tests.py b/backend/videoflix/content/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/videoflix/content/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/videoflix/content/views.py b/backend/videoflix/content/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/backend/videoflix/content/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/backend/videoflix/videoflix/settings.py b/backend/videoflix/videoflix/settings.py index 8030a52..03d4ba9 100644 --- a/backend/videoflix/videoflix/settings.py +++ b/backend/videoflix/videoflix/settings.py @@ -51,6 +51,7 @@ INSTALLED_APPS = [ 'rest_framework.authtoken', 'rest_framework', 'corsheaders', + 'content', 'users', ] @@ -83,6 +84,9 @@ TEMPLATES = [ }, ] +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +MEDIA_URL = '/media/' + WSGI_APPLICATION = 'videoflix.wsgi.application' # Database diff --git a/backend/videoflix/videoflix/urls.py b/backend/videoflix/videoflix/urls.py index ba52fa5..c9a0e99 100644 --- a/backend/videoflix/videoflix/urls.py +++ b/backend/videoflix/videoflix/urls.py @@ -16,6 +16,8 @@ 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 from users import views from auth.views import LoginView, RegisterView, VerifyEmailView, AuthView, ForgotPasswordView,ChangePasswordView @@ -28,6 +30,5 @@ urlpatterns = [ path('auth/register/', RegisterView.as_view()), path('auth/verify-email/', VerifyEmailView.as_view()), path('auth/forgot-password/', ForgotPasswordView.as_view()), - path('auth/change-password/', ChangePasswordView.as_view()), - -] + path('auth/change-password/', ChangePasswordView.as_view()), +] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)