daGrevis
daGrevis

Reputation: 21333

How to locally test Django project accessing it using example.com domain?

I'm willing to test Django project, but I want to access it using “example.com“. Before I used “127.0.0.1:8000“ (manage.py runserver), but now I have need to test how my project acts on different TLDs. All I want to do is somehow tell my computer that “example.com“ points to “127.0.0.1:8000“. I don't want others to have access to it, so it's not question about deployment.

I am Linux user. Any help would be much appreciated!

Upvotes: 0

Views: 578

Answers (4)

user1301404
user1301404

Reputation:

Simple, edit your hosts file at /etc/hosts so that your site "example.com" maps to the localhost "127.0.0.1"

Upvotes: 0

Daniel Roseman
Daniel Roseman

Reputation: 599630

Just edit /etc/hosts so that example.com maps to that 127.0.0.1.

I don't think you can map it to a specific port number though, so you'll need to either access example.com:8000 or run the server on port 80 (probably via sudo).

Upvotes: 0

gcochard
gcochard

Reputation: 11744

sudo vi /etc/hosts and add the following line at the end.

127.0.0.1 example.com

Also, if you run the web server as root, you can use port 80 and not have to type example.com:8000 into the address bar.

Upvotes: 2

YardenST
YardenST

Reputation: 5256

change the hosts file at /etc/hosts

Upvotes: 0

Related Questions