Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LazySite 'shadows' Site name #93

Open
gregbrowndev opened this issue Feb 21, 2019 · 0 comments
Open

LazySite 'shadows' Site name #93

gregbrowndev opened this issue Feb 21, 2019 · 0 comments

Comments

@gregbrowndev
Copy link

Using host_site callback in hosts.py, as per the documentation, e.g.

host_patterns = patterns('',
    host(r'www', settings.ROOT_URLCONF, name='www'),
    host(r'publish', 'publish.urls',
         callback='django_hosts.callbacks.host_site',
         name='publish'),
)

resolves and makes available the Site object for the host at request.site. However, the LazySite object that wraps the Site object shadows the name property of the Site record with the host name, i.e:

class LazySite(LazyObject):

    def __init__(self, request, *args, **kwargs):
        super(LazySite, self).__init__()
        self.__dict__.update({
            'name': request.host.name,
            'args': args,
            'kwargs': kwargs,
        })

    # other code ...

This means on the publish subdomain, accessing request.site.name returns the host name 'publish' (which can easily be accessed at request.host.name) rather then the site name, e.g. 'Publishing Service'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant