how to pass file from local storage to html using django

So i was using form to input file from html to local storage using django (im NOT using database / modals). Now i want get my file again and shown to my html. the file is song (mp3), so i want, the song what i uploaded to local storage can be played in web html.

but i don’t know how to pass it. please explain and help me. thank you

You want to use a model in your application to keep track of the file. It’s going to make everything easier that way.

i want but i don’t use database. it’s make me must use form, because i just want to keep my file to local storage. or can i use models without use database? or maybe can i use formset to get file from local?

If you are using Django, you will have a database. Django requires one for its operation.

When using a FileField, the files don’t get stored in the database - they get stored in the file system. The FileField tracks the location of the files, giving you an easy means of accessing those files later.

ah i see. i was using FileField. How to get the data then? Here’s my code :slight_smile:

class Audio_store(forms.Form):

    password=forms.FileField(widget=forms.FileInput(attrs={'style': 'width: 300px;', 'class': 'form-control',

    'text-align' : 'center;'}))

    audio=forms.FileField(widget=forms.FileInput(attrs={'style': 'width: 300px;', 'class': 'form-control',

    'text-align' : 'center;'}))

See the docs at:

could you give me references not using models? because i don’t use models and database

You want to use a model in your application to keep track of the file. It’s going to make everything easier that way.

i know, but my project not gonna use model. because, i don’t use and make database. so i’m using form.

It’s not an either / or situation. You use a form to get input from the browser. You save that data in the models. You use the models to save the data in the database. Forms don’t save data.
In other words, the two features work together. (Forms and models)

So i can use model without must make database and use it? how to save data to models from form without database then?

No. You will have a database, you can’t run Django at all without one.

but i can start my program now and i don’t use database or make it

Please post the contents of your file.

here’s all my file, sorry late to reply


Django settings for MusicLockApp project.

Generated by 'django-admin startproject' using Django 3.0.14.

For more information on this file, see

For the full list of settings and their values, see


import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production

# See

# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = 'rkle8apj*z6j%&(@&-za$9e5o-0m1^#hr5&lk0@f-_=koz25i&'

# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True


# Application definition






















ROOT_URLCONF = 'MusicLockApp.urls'



        'BACKEND': 'django.template.backends.django.DjangoTemplates',

        'DIRS': ['templates', 'assets'],

        'APP_DIRS': True,

        'OPTIONS': {

            'context_processors': [









WSGI_APPLICATION = 'MusicLockApp.wsgi.application'

# Database



    'default': {

        'ENGINE': 'django.db.backends.sqlite3',

        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),



# Password validation




        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',



        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',



        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',



        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',



# Internationalization




USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)


STATIC_URL = '/static/'


    os.path.join(BASE_DIR, 'assets'),


MEDIA_URL = '/media/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

You are using a database.

It’s defined right here:

but i mean, i don’t make database for saving something

That’s a different issue, and will change for you to be able to do what you want to do.

what do you mean will change it? so i can use it to get my file from local?

I mean, if you want to build the application you want to build, you will start using that database.