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

Allow subdomain-aware URL reversing to work when serving on non-standard port #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ezheidtmann
Copy link

This enables {% url ... subdomain='something' %} and reverse() to produce
useful results when used in runserver. Tested with runserver_plus.

…ard port

This enables {% url ... subdomain='something' %} and reverse() to produce
useful results when used in runserver. Tested with runserver_plus.
@ezheidtmann ezheidtmann reopened this Feb 20, 2015
@ezheidtmann
Copy link
Author

Yay! Travis likes it!

The attribute was added in Django 1.7, so we use None if it is not available in
order to maintain compatibility with earlier versions.
@ezheidtmann
Copy link
Author

Also added support for automatically determining the scheme (http/https) from the request if present in the template.

@lionleaf
Copy link

Currently running into this issue. Would be great to have this merged. Any workarounds for now? (For testing on localhost:8000 get it to return subdomain.localhost:8000/path on reverse)

@hakanw
Copy link

hakanw commented Jan 25, 2016

Very much +1 on this, if this means it solves the problems when using this app during development on localhost!

@lionleaf
Copy link

@hakanw I fixed this by adding the port to the site domain on localhost, and it now works well even with the 8000 port.

That is, in the django shell run:

>>> from django.contrib.sites.models import Site
>>> site = Site.objects.all()[SITE_ID]
>>> site.domain = 'localhost:8000'
>>> site.save()

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

Successfully merging this pull request may close these issues.

3 participants