Cookiecutter-django: Setting of admin location on heroku

Created on 9 Oct 2015  路  4Comments  路  Source: pydanny/cookiecutter-django

I've been unable to set the admin location with the new DJANGO_ADMIN_URL env if I set it to say
DJANGO_ADMIN_URL=r'^random/'
Then browsing to myapp.herokuapp.com/random just produces a 500 error. Not clear what the issue is? (Set in bash with:
heroku config:set DJANGO_ADMIN_URL=r'^random/'
also confirmed its set via heroku dashboard)

Most helpful comment

Remove the r' at the beginning and ' at the end so that it reads:

DJANGO_ADMIN_URL=^random/

All 4 comments

Remove the r' at the beginning and ' at the end so that it reads:

DJANGO_ADMIN_URL=^random/

Thanks @jayfk that made it work perfectly. I'm not 100% why the r' isn't needed as in urls.py it's set as:
url(settings.ADMIN_URL,....)
so not sure how it gets added in?
I'll add a line into the heroku deployment docs when I get a moment.

In urls.py you have to set the urls in python syntax with quotes, but we are getting the value parsed from environ as a string. If you set the environment variable to r'foo', the variable is parsed as if you would write "r'foo'" in urls.py.

r'' is basically a special version of the of the _normal_ python '' string with a special behaviour. You can read more about that here: http://stackoverflow.com/questions/2081640/what-exactly-do-u-and-r-string-flags-do-in-python-and-what-are-raw-string-l

got it- thanks for the clear explanation

Was this page helpful?
0 / 5 - 0 ratings