Maintaining a Django admin site on a subdomain

I have a project running Django, uWSGI and Nginx. I am currently using the default Django admin site which runs in example.com/admin

. I want to change this so that the admin site is only accessible in admin.example.com

.

What's the best way to do this?

I thought about starting a completely new Django project that will be served on admin.example.com

, but with the same database settings as the project that is running example.com

, but I'm hoping for something more elegant as it involves duplicating a lot of settings and applications between projects. Basically, the only difference between the two would be that it would have an admin site and URL pattern set, and one wouldn't.

(My reason is that you end up wanting to use something like google auth proxy to secure the admin site, but skip the no admin login, how can I do this by specifying that Django uses HTTP Basic Auth for admin.example.com

, but stick to the default backend for example.com

.)

+3


source to share


1 answer


Just create a new settings file that includes the original settings and defines a custom parameter ROOT_URLCONF

. Now you just need to deploy the application with this DJANGO_SETTINGS_MODULE

in this admin subdomain.

eg:.

settings_admin.py



from settings import *
ROOT_URLCONF = 'urls_admin'

      

urls_admin.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
    url(r'', include(admin.site.urls)),
)

      

+5


source







All Articles