Prefix Django base URL pattern

313 Views Asked by At

My service implemented in Django is hosting iCal calendar files. I want this files to be opened as a webcal stream, but this requires URL to be composed in a certain way so that browser/system/another service understands what should it do to handle this file properly. The URL should look like this: webcal://myservice.com/icalfile, but the URL pattern in Django starts only at myservice.com base url, for example:

url(r'^/icalfile$', views.ReturnICS.as_view())

is the equivalent of:

myservice.com/icalfile

Although I can explicitly insert webcal:// to a url for each ical file represented in a template and pass it as variable when rendering view, like this for instance:

ics_url = 'webcal://' + icalfileurl

I'd very much like to find a way to compose a full url pattern that already has 'webcal://' part included, something like:

url(r'webcal://^*/icalfile$', views.ReturnICS.as_view())

* – is where base URL is. but Django does not recognise this construction.

0

There are 0 best solutions below