0

How can i change the default address http://127.0.0.1:8000/ to something useful like a proper sitename.

I am using the development server that comes with Django.

I googled for about 1 hour but could not find a proper solution.I am a beginner so please help me out.

How can I, on my local machine, be able to use a host name instead of the loopback address?

Oded
  • 489,969
  • 99
  • 883
  • 1,009
Dhiraj Thakur
  • 716
  • 10
  • 25
  • i am using the development server that comes with Django itself... – Dhiraj Thakur Sep 01 '12 at 16:07
  • Get a web host and a domain name. Money will need to change hands. – Oded Sep 01 '12 at 16:08
  • @Oded : i wanted to know can i do this on my own machine while developing the app....i know i can get a web host and domain name with money! – Dhiraj Thakur Sep 01 '12 at 16:12
  • Why? I think you would get more specific answers if you included the reason for doing it. Do you want to make the development server available in your internal network (this is easy), to the internet (usually a bad idea), something else? All in all this question seems to be more realted to general networking configuration than a concrete Django problem. Including the OS you are using would also be helpful. – Dirk Eschler Sep 01 '12 at 16:44

2 Answers2

8

Change your hosts file add an entry like:

127.0.0.1 www.google.com 

At this point whenever you try www.google.com you will redirect to your own machine.

You will probably still need to use the same port, so changing the port to port 80 (the default for http traffic) will mean it is not needed on the URL.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • is this host file available in the default Django server..? – Dhiraj Thakur Sep 01 '12 at 16:16
  • @dkt, this hosts file is the setting of your operating system, not Django itself. This file is responsible for translating particular domains into IP adresses prior to more global DNS lookups. So there you store your local settings. – spacediver Sep 01 '12 at 16:16
  • @dkt - The `hosts` file is the OS one. I did provide a link - perhaps read the contents? – Oded Sep 01 '12 at 16:17
  • So..when we upload our Django site to a web server do we have to edit the host file on that web server..? – Dhiraj Thakur Sep 01 '12 at 16:19
  • @dkt - No. The internet infrastructure includes [DNS](http://en.wikipedia.org/wiki/Domain_Name_System) (translates host names to IP addresses). When you buy a domain and host it, you also pay for the DNS entry - so your domain will point to where it is hosted. – Oded Sep 01 '12 at 16:21
  • dkt: no, you don't have to. Django probably has docs on deployment, check em. I don't think you need to mess with any hosts file at all, your question is just so naively phrased (sorry). – Markus Unterwaditzer Sep 01 '12 at 16:22
  • @MarkusUnterwaditzer : So i can do this only if i deploy my app with Apache etc. and not with Django's server ? – Dhiraj Thakur Sep 01 '12 at 16:24
  • @dkt: Both Django and Apache could be part of your setup. Look for a webhoster and then look for a tutorial on how to deploy your Django application there. – Markus Unterwaditzer Sep 01 '12 at 16:27
0

DNS is your friend...
Or /etc/hosts...

Zulu
  • 8,765
  • 9
  • 49
  • 56