[Fixed]-Get file name from Django Document object

1πŸ‘

βœ…

In python you can get that using name attribute.,.

newdoc = request.FILES['docfile']
newdoc.name # file name

Andv if you wish to see that in the template here is the code

{% for document in documents %}
{{ document.file.filename }}
{% endfor }}

In the model objects

newdoc = Document.objects.get(id=1)
newdoc.docfile.url # url of the file
newdoc.docfile.path # exact path
πŸ‘€Raja Simon

Leave a comment