Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 322927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:59:02+00:00 2026-05-12T08:59:02+00:00

Probably simple question and I’m just missing something, but I’m stuck out of ideas.

  • 0

Probably simple question and I’m just missing something, but I’m stuck out of ideas.

I have Django project serving several sites with distinct sessions.py and completely different ROOT_URLCONFs. One site handles user registration, authentication and profile settings, other site (on another domain) acts as file manager and so on. Sites are sharing the same DB, media and templates. All sites are sharing the same userbase, implementing sort of transparent single-sign-on/single-sign-off mechanism. It is just like one big site, spanning across several domains.

The problem is, I have a lot of {% url %} tags in my templates, and they don’t work when template’s used on other sites. And I’d like to avoid hardcoding URLs as much as possible.

For example, on site A (a.example.org) I have an

url('^users/$', 'example.accounts.list_users', name='list_users'),

entry in A’s URLconf. Then, in some global_menu.html template I have {% url list_users %} and obviously it works perfectly, resulting in “/users/“.

Now, there’s site B (b.example.org), sharing a lot of internals with A. To have common look-and-feel I want to use the same global_menu.html on site B and want {% url list_users %} to output “http://a.example.org/users/“. What’s the best way I can achieve this?

Currently, I’m using separate global_menu.html for each site, but this violates DRY principle, and not really convenient. And, yes, I’m using Django’s contrib.sites framework with distinct SITE_IDs defined in settings.py for each site, but not yet actually using it anywhere else.

Update: Currently I’m thinking of reimplementing url tag or monkey-patching reverse(), to call the original one, and on exceptions perform additional look up in some “foreign URI list”. If there already exists anything like this — I’d be happy to hear.

Thank you in advance for answers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:59:02+00:00Added an answer on May 12, 2026 at 8:59 am

    I’ve implemented it by overriding django.core.urlresolvers.reverse with my custom function:

    from django.core import urlresolvers
    from django.conf import settings
    
    __real_reverse = urlresolvers.reverse
    
    def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None):
        try:
            return __real_reverse(viewname, urlconf, args, kwargs, prefix)
        except urlresolvers.NoReverseMatch, no_match:
            external_urlconfs = getattr(settings, 'EXTERNAL_URLCONFS', [])
            for p, c in external_urlconfs:
                c = urlresolvers.RegexURLResolver(r'^/', c)
                try:
                    return p + c.reverse(viewname, *args, **kwargs)
                except urlresolvers.NoReverseMatch:
                    pass
            raise no_match
    
    urlresolvers.reverse = reverse
    

    Then listing URLconfs in settings.py like this:

    ROOT_URLCONF = 'project.urls_a'
    
    EXTERNAL_URLCONFS = (
        ('http://b.example.com/', 'project.urls_b'),
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a simple question that I am just missing but I have
This is probably a simple question but I can't seem to figure out how
This is probably a simple question, but i have been unable to find a
This is probably a really simple question but one I've never quite worked out
I have a probably pretty simple question but I am still not sure! Actually
This is probably a simple question for you php whizzes out there but I
This is probably a simple question, but it's driving me crazy! I have a
This is probably a simple question, but the answer is eluding me. I have
I know this is probably a simple question but, I have a ASP.NET WebSite
Probably a simple question but I only have Linux to test this code on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.