Is it possible to have a prefix when using the reverse function?
I have reverse('foo') that point to www.bla.com/foo
but the URL needs to be www.bla.com/bla2/foo
So the bla2 would be the prefix
If '/bla2' is the mount point for your Django application, with a correctly setup WSGI server you should not need to do anything to add it. This is because the WSGI server should already be sending through
SCRIPT_NAME set as '/bla2' and Django should insert that automatically at the front of URLs constructed using reverse().
Can you explain what WSGI server you are using and/or whether you have it hosted behind a proxy front end that is publishing the site at a different URL mount point to the backend.
If you do have this situation where a front end is proxying as '/bla2', but the backend has it mounted at '/'. Then the Django setting you need to specify to force the backend to use '/bla2' and so insert the correct prefix is
Note that this affects the whole site.
if you need
www.bla.com/bla2/foo then your
foo url should be pointing to
Other way to perform that, is creating a final url, something like this:
final_url = prefix + reverse('foo')
reverse('foo') will output