views:

32

answers:

1

I have an app that serves pages like this /stage/stagename. stagename is variable. The URL mappers just look for a [0-9A-Za-z]+ to fill that slot.

Now, because of my setup, My app will be rooted at /stage/stagename. I cannot change this (without massive changes to my setup which is too tedious right now and a last option).

I need to use django.contrib.auth. The login and logout URLs can't be in my settings file since they will change depend on where my app is rooted (For one it might be /stage/foo/login and for the other, it might might /stage/bar/login).

How can I make the backend use such dynamic URLs?

I also have the issue that I need to pass the stagename parameter to the template which generates my URL. How can I do that?

A: 

/stage/foo/login and for the other, it might might /stage/bar/login).

url( r'^stage/(?P<name>[^/]+)/login/$', some_view_function )

Might be what you're looking for.

However, you seem to have bigger problems than this. "massive changes to my setup which is too tedious" indicates more serious and fundamental problems.

S.Lott
I have something like this but I can't put this in my `settings.py`. It has to be hardcoded there.
Noufal Ibrahim
That's not supposed to be in your settings.py. That's supposed to be in your urls.py. What are you doing?
S.Lott
`LOGIN_URL = '/login'` in the `settings.py` to give it the URL to which it should redirect to present the login form. I'm using a slightly older version of Django for which I can't pass the `login_url` parameter to the decorator.
Noufal Ibrahim