tags:

views:

200

answers:

1

Can you configure a Django development server to handle wildcard sub-domains? I need to test any arbitrary sub-domain on my dev server and this is not possible by modifying the /etc/hosts/

The subdomain actually controls key behavior on the site (each user gets their own sub-domain and a user can have access to multiple sub-domains requiring non-trival testing on development.)

+1  A: 

If I understand your question correctly, the Django development server is not the problem. You will have to set up your DNS server to handle wildcard records or add specific subdomains to your hosts file.

As I'm sure you're aware of, the Django dev server defaults to using 127.0.0.1:8000 but you can override this. If you override it with localhost it's likely handled by your /etc/hosts file and not by DNS. If you override it with something not in the /etc/hosts file, it is handled by DNS.

The easy case of adding specific subdomains in the /etc/hosts file, you've already covered in your question. Unfortunately you can't set up your hosts file to handle wildcard subdomains, for that you need to setup DNS (OSX Snow Leopard instructions).

Now — if you're okay with only testing through Firefox, you can solve the problem in a much easier way by using proxy autoconfiguration. See the answers to this StackOverflow question.

lemonad
Running OSX. Does DNS affect going to the localhost? Please elaborate.
MikeN
Extended my answer now, hope it helps!
lemonad