'how to make custom form without database - DJANGO

So i want to upload file but only sent to locals storage NOT DATABASE too. But i don't know how to make custom forms.

suddenly, here's my models.py :

from django.db import models

class Audio_store(models.Model):
    record=models.FileField(upload_to='mp3/')

forms.py :

from django import forms 
from .models import Audio_store

class AudioForm(forms.ModelForm):
    class Meta:
        model = Audio_store

urls.py :

from django.contrib import admin
from django.conf.urls import url
from . import views
from django.urls import path, re_path
from django.conf import settings
from django.conf.urls.static import static


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^decode/$', views.decode),
    url(r'^$', views.homepage),
    path('audio', views.Audio_store),
]

if settings.DEBUG: #add this
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
            fields= ['record']

html:

<form method="POST" enctype="multipart/form-data">
                            {% csrf_token %}
                            {{form}}
                            <button type="submit" class="dsnupload">
                                <i class="large material-icons" style="font-size: 50pt; margin-top: 10px;">audiotrack</i>
                                <p style="font-weight: bold; color: white;">Insert file audio (mp3)</p>
                            </button>
                            </form>


Solution 1:[1]

Django has forms.ModelForm which requires DB model and forms.Form which you can use without any model.

https://docs.djangoproject.com/en/4.0/topics/forms/#the-form-class

from django import forms

class YourForm(forms.Form):
    upload_file = forms.FileField()

for the fileinput refer https://docs.djangoproject.com/en/4.0/ref/forms/fields/#django.forms.FileField

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rahul.m