# How to upload a video to django ?

**URL:** https://forum.djangoproject.com/t/how-to-upload-a-video-to-django/38697
**Category:** Forms & APIs
**Created:** [February 8, 2025, 11:24pm UTC](https://forum.djangoproject.com/t/how-to-upload-a-video-to-django/38697 "2025-02-08T23:24:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mabaashar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mabaashar/32/23552_2.png) [@mabaashar](https://forum.djangoproject.com/u/mabaashar)
#### Post date: [February 8, 2025, 11:24pm UTC](https://forum.djangoproject.com/t/how-to-upload-a-video-to-django/38697/1 "2025-02-08T23:24:48Z")

</div>

I want to upload a video via a ModelForm to my view to process it then display the result in the front-end.

My approach is:

**models.py**

from django.db import models

class Video\_upload(models.Model):  
user = models.ForeignKey(User, on\_delete=models.CASCADE)  
video = models.FileField(blank=True,upload\_to=‘static/video/’)

**forms.py**

```auto
from django.db import models
from django import forms
from django.forms import ModelForm

from myapp.models import Video_upload

class VideoUploadForm(ModelForm):
    video = forms.FileField(required=False, error_messages = {'invalid':("Video files only")}, widget=forms.FileInput)
    class Meta:
        model = Video_upload
        fields = ['video']

```

**views.py**

```auto
def main(request):
    template = loader.get_template('index.html')
            model_db = Model_info.objects.get(id=chosen_model)
        if request.POST:
            form = VideoUploadForm(request.POST, request.FILES)
            # video_form = VideoUploadForm(request.POST,request.FILES)
            if form.is_valid():
                # get uploaded video
                uploaded = form.cleaned_data['video']
                v_name = request.FILES['video'].name
                [[[[[??My question is here??]]]]]

```

How do I get the video that was uploaded through the form ? I can get its name only.

Notice that I don’t want to store it permenantly, just temporarily until the processing completes and yeild a result.

---

<div class="post-metadata">

### Author: ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)
#### Post date: [February 8, 2025, 11:43pm UTC](https://forum.djangoproject.com/t/how-to-upload-a-video-to-django/38697/2 "2025-02-08T23:43:57Z")

</div>

If you want to process the video before it’s saved, see the docs at [File Uploads | Django documentation | Django](https://docs.djangoproject.com/en/5.1/topics/http/file-uploads/) , especially the section on [Upload Handlers](https://docs.djangoproject.com/en/5.1/topics/http/file-uploads/#upload-handlers).

Note: If you’re not going to save it, then you do _not_ want to make a model for this, and you don’t want to create the form as a model form. Create a regular form for this and process the file in a handler.

---

<div class="post-metadata">

### Author: ![mabaashar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mabaashar/32/23552_2.png) [@mabaashar](https://forum.djangoproject.com/u/mabaashar)
#### Post date: [February 10, 2025, 10:55pm UTC](https://forum.djangoproject.com/t/how-to-upload-a-video-to-django/38697/3 "2025-02-10T22:55:56Z")

</div>

Thank you very much @KenWhitesell , I followed the approach you suggested and managed to upload the video successfully.

I used normal form.
