I am rendering a simple form with a file field.
class ReviewForm(forms.ModelForm):
class Meta:
model = Review
fields = [
'file',
]
widgets = {
'file': forms.ClearableFileInput(),
}
While rendering, the form shows Current file - /xyz/xyz/xyz.pdf
besides the file input.
However, I do not allow direct access to the files. All requests goes through the analytics_logger function before loading the file.
So, I want to customise the Current file
html from
Current file - <a href="{0}">{1}</a>
to
Current file - <a href="{% url 'analytics_logger' {0} %}">{1}</a>
I also don't want to display the full path of the file. Only the filename should be displayed.
How can I do it in Django 3.x?