Skip to content

Commit

Permalink
Merge pull request #9 from turtleslayz/main
Browse files Browse the repository at this point in the history
Django handling user upload
  • Loading branch information
MAlshaik authored Feb 22, 2023
2 parents 8cb0b8c + 2bff6d7 commit 8bac7fd
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Frontend/Home.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load static%}

<!DOCTYPE html>
<html>
<head>
Expand Down
4 changes: 3 additions & 1 deletion Frontend/video-editing.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

<div id="wrapper">
<header>Upload A Video File</header>
<form action="#">
<form method ="POST" enctype = "multipart/form-data">
<!-- {% csrf_token %} -->
<!-- {{ form.as_p }} -->
<input class="file-input" type="file" name="file" hidden>
<i class="fas fa-cloud-upload-alt"></i>
<p>Browse File to Upload</p>
Expand Down
7 changes: 7 additions & 0 deletions transcription/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django import forms
from .models import UserUpload

class VideoForm(forms.ModelForm):
class Meta:
model= UserUpload
fields= '__all__'
2 changes: 2 additions & 0 deletions transcription/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.db import models

# Create your models here.
class UserUpload(models.Model):
UserVideo = models.FileField( blank=True, null=True)
17 changes: 17 additions & 0 deletions transcription/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import render
from .models import UserUpload
from .forms import VideoForm

def showvideo(request):


form= VideoForm(request.POST, request.FILES)
if form.is_valid():
form.save()

context= {
'form': form
}


return render(request, 'video-editing.html', context)

def index(request):
return HttpResponse("Hello, world. You're at the transcription index.")
Expand Down
4 changes: 4 additions & 0 deletions transcriptsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@

STATIC_URL = 'static/'

MEDIA_URL = '/media'
MEDIA_ROOT = BASE_DIR / 'uploads'


# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

Expand Down
4 changes: 3 additions & 1 deletion transcriptsite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"""
from django.contrib import admin
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('transcription/', include('transcription.urls')),
path('admin/', admin.site.urls),
]
] + static(settings.MEDIA_URL, document_root= settings.MEDIA_ROOT)

0 comments on commit 8bac7fd

Please sign in to comment.