Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics What a View! Running the Server

Sexual Potatoes
Sexual Potatoes
12,051 Points

How do I view what's on the "preview" button of the Workspace in my browser?

I'm trying to run the project on my computer instead of in Workspace, since it simulates a real environment.

4 Answers

This may be bad advice but if you're getting the "disallowed host" message, you can go into settings.py and look for a variable called ALLOWED_HOSTS, it's an empty list.

Put the string "0.0.0.0" into that list and run the server again, it should work.

Moin shamsi
Moin shamsi
7,579 Points

I have the same problem and added the above address of "0.0.0.0" to ALLOWED_HOSTS, but it doesn't work. The message on my browser is: " Firefox can’t establish a connection to the server at 0.0.0.0.

The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web."

I stopped my antivirus and firewall also, but still can not load the page! Does anyone can help please?

Simin Hajizadeh
Simin Hajizadeh
3,072 Points

I am using other workspace instead of what you use, I can't preview my URL, I wrote ['0.0.0.0'] in setting.py but it does'nt work. would you please help me how I can preview my URL?

Sameer Zahid
Sameer Zahid
5,967 Points

http://127.0.0.1:8000/

Type that in the browser. I'm using a virtualenv, and didn't know how to view it either. I think the above is equivalent to saying: "server is localhost and port is 8000", but I'd appreciate someone with more experience to comment on this.

Haydar Al-Rikabi
Haydar Al-Rikabi
5,971 Points

As Sameer has mentioned, you can try: http://127.0.0.1:8000/ The following will yield the same result: http://localhost:8000/