I have the doubt of which is the correct way to save videos or upload them, in Django.
The field
one that could work, I think, would be a FileField
, but is this a good option or alternative?
I also saw a proposal out there to have a field FilePathField
, having the video paths there and thus accessing them when necessary, but I'm not very convinced.
Any suggestion helps my learning. Thanks in advance for your answers!
What you need is a type field
FileField
, since itFilePathField
is like aCharField
but with some extra methods to find files in a "fuzzy" way.What you have to do is declare a type field in your model
FileField
and in the parameterupload_to
put the path relative to the folder to which you want your files to be uploaded.Remember to have your file well configured
settings.py
with the variablesMEDIA_ROOT
andMEDIA_URL
since the files will be uploaded to theMEDIA_ROOT
/relative_path folder that you placed in your model.More info here FileField .