Django Class Based Views Download Video YouTube return 404 not found in File

I’m developing a website for training in Django (Class Based View) that downloads a video that the user informs the URL on the front end. However, when returning the exact URL, Django appears as 404 - Not Found. How can I pass the parameter to download the file?

In urls.py I already inserted + static (settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) to download the static files

Below are the files:

views.py

class PaginaPrincipal(TemplateView):
template_name = 'home/index.html'

def get(self, request, *args, **kwargs):
    if not os.path.exists('media/'):
        os.makedirs('media', exist_ok=True)
    for file in glob.glob('media/*.mp4'):
        if file:
            os.remove(file)
    return render(self.request, self.template_name)

def post(self, request):
    link = str(self.request.POST.get('link-youtube'))
    if link:
        func.videoDownload(link)
        return redirect(reverse_lazy('pagina-resultado'))
    return render(request, 'error.html', {'error': 'erro ao baixar, tente novamente'})

class PaginaResultado(TemplateView):
  template_name = 'home/result.html'

def get_context_data(self, **kwargs):
    context = super(PaginaResultado, self).get_context_data(**kwargs)
    arquivo = None
    for file in glob.glob('media/*.mp4'):
        arquivo = file
    context['videoDownload'] = arquivo
    return context

func.py

def videoDownload(url):
yt = YouTube(url)
yt.streams.order_by('resolution')[-1].download()
movingFileToCorrectPath(flag='video')
yt.streams.filter(only_audio=True)[-1].download()
movingFileToCorrectPath(flag='audio')
joinFile()
title = yt.title
urlVideo = 'https://www.youtube.com/watch?v=' + yt.video_id
views = yt.views
thumbnail = yt.thumbnail_url
author = yt.author
renameLastFile(title=title)
# print(title, urlVideo, views, thumbnail, author)



def movingFileToCorrectPath(flag):
if not os.path.exists('/static/video'):
    os.makedirs('static/video', exist_ok=True)

try:
    if flag == 'video':
        for file in glob.glob('*.webm'):
            os.renames(file, f'video-{file}')
            a = f'video-{file}'
        shutil.move(a, 'static/video/')
    elif flag == 'audio':
        for file in glob.glob('*.webm'):
            os.renames(file, f'audio-{file}')
            a = f'audio-{file}'
        shutil.move(a, 'static/video/')
    return
except Exception as e:
    print(e)


def joinFile():
arquivos = []
for file in glob.glob('static/video/*.webm'):
    arquivos.append(file)
arquivo1 = arquivos[0]
arquivo2 = arquivos[1]
joinFile = f'ffmpeg -i "{arquivo1}" -i "{arquivo2}" -c:v copy -c:a aac static/video/videofull.mp4'
os.system(joinFile)
for file in glob.glob('static/video/*.webm'):
    os.remove(file)
return

def renameLastFile(title):
for x in glob.glob('static/video/*.mp4'):
    os.renames(x, f'media/{title.replace(" ", "")}.mp4')

index.html

<div class="s003">
  <form method="post">
    {% csrf_token %}
    <div class="inner-form">
      <div class="input-field second-wrap">
        <input type="url" name="link-youtube" placeholder="https://www.youtube.com/watch?v=4wYe0oYL3Z8" required/>
      </div>
      <div class="input-field third-wrap">
        <button class="btn-search" type="submit">
          <svg class="svg-inline--fa fa-search fa-w-16" aria-hidden="true" data-prefix="fas" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
            <path fill="currentColor" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"></path>
          </svg>
        </button>
      </div>
    </div>
  </form>
</div>

result.html

<div class="s003">
  <form>
    {% csrf_token %}
    <div class="inner-form">
      <div class="input-field second-wrap">
        <input type="url" name="link-youtube" placeholder="https://www.youtube.com/watch?v=4wYe0oYL3Z8" required/>
      </div>
      <div class="input-field third-wrap">
        <button class="btn-search" type="submit">
          <svg class="svg-inline--fa fa-search fa-w-16" aria-hidden="true" data-prefix="fas" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
            <path fill="currentColor" d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"></path>
          </svg>
        </button>
      </div>
    </div>

      <a href="{{ sendingFileToTemplate }}" class="btn btn-primary btn-lg btn-block">clique aqui para baixar</a>

  </form>
</div>