Set script prefix in django.setup() to allow its usage outside of requests
|Reported by:||d00gs||Owned by:||nobody|
|Component:||Core (Management commands)||Version:||master|
|Cc:||julenx@…, AkosLadanyi||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The script prefix for django.core.urlresolvers doesn't get set to anything when being called through manage.py, because of course it doesn't know what that value should be. This is a problem if you're rendering views (or otherwise reversing urls) from a manage.py command (as one of my sites does to send emails).
This is solvable by calling set_script_prefix from settings.py, but that feels kind of dirty since it's then about to be rewritten in the WSGI handler.
I don't know what a good solution to this would be. Perhaps it would be nice to be able to set a global default script path somewhere that would then get incorporated into the default values of things like LOGIN_URL.
Maybe just a note in the documentation would be good. It took me a while to figure out, because I haven't been able to find anything else about this online. (I guess that non-/ script paths are uncommon and reversing urls from manage.py is also uncommon, so both together are very uncommon.)
Change History (12)
comment:1 Changed 5 years ago by aaugustin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:9 Changed 10 months ago by claudep
- Has patch set
- Needs documentation set
- Version changed from 1.3 to master
comment:11 Changed 10 months ago by timgraham
- Summary changed from urlresolvers doesn't get a script prefix from manage.py to Set script prefix in django.setup() to allow its usage outside of requests
- Triage Stage changed from Accepted to Ready for checkin
- Type changed from Bug to New feature