jazzband / django-hosts

Dynamic and static host resolving for Django. Maps hostnames to URLconfs.
http://django-hosts.rtfd.org
Other
982 stars 106 forks source link

host_url tag does not preserve server port #5

Closed jlirochon closed 9 years ago

jlirochon commented 12 years ago

Development server is running at http://127.0.0.1:8000/

Urls generated by host_url tag do not contain ":8000". Fixing the port in settings.PARENT_HOST can help, but not for tests.

I'm running tests with django.test.LiveServerTestCase (Django 1.4). Live server port can not be predicted, it would be nice to determine the actual port at runtime.

jezdez commented 12 years ago

Can you post a bit more information about the configuration you're running?

erikcw commented 12 years ago

I'm running into a similar issue. I'm having to append the django dev server (manage.py runserver) port to my hosts for it to work in dev and testing.

My hosts file:

host_patterns = patterns('',
    host(r'www', settings.ROOT_URLCONF, name='domain1'), #DEFAULT_HOST = "maindomain.com"
    host(r'example\.com:5000', 'example.urls', name='domain2'),
 )

This more general version doesn't work

host_patterns = patterns('',
    host(r'www', settings.ROOT_URLCONF, name='domain1'), #DEFAULT_HOST = "maindomain.com"
    host(r'example\.com', 'example.urls', name='domain2'),
 )

There should be an option to either ignore port numbers in FQDN hosts, set a default. People don't generally run the dev server on port 80 since it is privileged and not the Django default.

Ideally there would be an option to ignore, or keep the port. As this would add flexibility for those who need it in their setup.

jezdez commented 9 years ago

Yeah, fixing is coming..