Add a (canonical) slug to django filer's files

I’m actually working on the way to add a custom slug on django-filer’s files. The slug, if given, will replace the automatically generated canonical URL (the one with with numbers)

It is actually working and I will be glad to submit a PR for this, but I have one question and one problem:

The question: Actually the generated canonical URL with numbers use the uploaded date in URL. I’m not sure why. Is it for security reasons ? Not to be able to easily download files just by guessing their id ?

The problem: actually there is no dynamic update of the “Canonical URL field” when filling the slug. I guess I will need to wrote a custom widget to handle this ? I never done that before. Any advice on writing such widgets ?

And more generally, what is your opinion or feeling on this development?


I’ve succeed to inject custom javascript in filer/change_form.html to dynamicaly change the canonical URL display. But i’m note sure it is a good idea since the field isn’t validated server side.

What is the benefit for being able to override that slug? This canonical URL is intended to be invisible anyway. Or did I miss something here.

Our use case is to send email with links to documents on the website. The links will be visible in the email body, so we need a nice link display. The documents are frequently updated but we want to keep the same link to not have to update the emails template each time, so the canonical way is what we need here.

PR submitted here: feat: add canonical URL slug on files by fabien-michel · Pull Request #1300 · django-cms/django-filer · GitHub