0
I have a model field which is a Fileupload and I want to extract the file through the queryset how can I do that?
Hi Guys I don't know if I can get some django advice In my django project I have a model and i the model I have a field which is a model.Fileupload() then I get to uplaod a file, now I want to access that file via the django queryset
4 odpowiedzi
+ 1
I will try that
I was trying to access the file through queryset but I couldn't get what I actually want
Thanks again 🤝🏽
0
If I got your question right, you are looking for url.
class YourModel:
its_file = FileField(upload_to=your_media_dir ...
And then you access the file eg via your_model_instance.its_file.url
See ( FileField ):
https://docs.djangoproject.com/en/4.1/ref/models/fields/
0
Hi, no it's not a url am looking for, the model field is Fileupload, then I uploaded a file from front-end now I want to extract the particular file using django queryset in the backend
Am not sure if my statement is understandable
Thank you for trying to help
0
I'm not sure if I got you right, but if you are trying to access the file itself, not the model, you can do something like:
import os
os.open(path_to_media_dir + your_model.file.url)