upload videos in the backend

This commit is contained in:
Chneemann 2024-08-11 09:05:13 +02:00
parent 4fe20b908e
commit bf0785bc78
9 changed files with 35 additions and 3 deletions

View file

View file

@ -0,0 +1,4 @@
from django.contrib import admin
from .models import Video
admin.site.register(Video)

View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ContentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'content'

View file

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

View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -51,6 +51,7 @@ INSTALLED_APPS = [
'rest_framework.authtoken', 'rest_framework.authtoken',
'rest_framework', 'rest_framework',
'corsheaders', 'corsheaders',
'content',
'users', 'users',
] ]
@ -83,6 +84,9 @@ TEMPLATES = [
}, },
] ]
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
WSGI_APPLICATION = 'videoflix.wsgi.application' WSGI_APPLICATION = 'videoflix.wsgi.application'
# Database # Database

View file

@ -16,6 +16,8 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from users import views from users import views
from auth.views import LoginView, RegisterView, VerifyEmailView, AuthView, ForgotPasswordView,ChangePasswordView from auth.views import LoginView, RegisterView, VerifyEmailView, AuthView, ForgotPasswordView,ChangePasswordView
@ -29,5 +31,4 @@ urlpatterns = [
path('auth/verify-email/', VerifyEmailView.as_view()), path('auth/verify-email/', VerifyEmailView.as_view()),
path('auth/forgot-password/', ForgotPasswordView.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)
]