On Oct 27, 1:53 pm, Christian Joergensen <m...@razor.dk> wrote:
>
> You could probably just read it from sys.argv ;)

;-) That had crossed my mind. I think it might actually be the most
robust way!

You have to do a bit of fiddling to make sure you don't grab an
option, and that you don't do this if you're not under runserver - but
this below is what I'm doing for now. It seems to Work For Me. This is
now in settings.py, with a bit of boilerplate to set some appropriate
variables.


def check_runserver_addrport():
    import sys
    if len(sys.argv) > 1 and sys.argv[1] == "runserver":
        addrport = sys.argv[-1] if len(sys.argv) > 2 else
"127.0.0.1:8000"
        if addrport.startswith("-"):
            return
        else:
           try:
                addr, port = addrport.split(':')
           except ValueError:
                addr, port = '', addrport
        if not addr:
            addr = '127.0.0.1'
        return addr, port
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to