views:

116

answers:

2

I'm just starting to learn Python and Django and an unable to get the most basic app working. I've setup Python, added python to the Path environment variable, installed Django using install.py script.

I created an app by running the command

django-admin.py startproject my_project

updated the settings.py file for a database

DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'mysitedb'

Ran the command

python manage.py syncdb

And finally, started everything up

python manage.py runserver

To this point, everything looks to have run successfully. When I got to view http://localhost:8000/ I get the error "Page not found: /"

I originally installed Django version 1.1, but got the same error, so I removed it and tried the older version 1.0.3. Niether work. Any help would be appreciated.

+1  A: 

It sounds like you need to create some apps for your project and set up the urls. As you are just starting you'd be best following the tutorial right through to get a feel for it all.

artran
I'm using the book Django Web Site Development by Ayman Hourieh. According to the book, it says at this point I should get a page which says:It Worked!Congratualtations on your first Django-powered PageOr course, you have actually done any work yet. Here's what to do next....However I get:Page not found: /I though the same thing as you, and moved on to the next section anyway. So i created an application:python manage.py startapp bookmarksEdited the view and updated urls.py however, got the same error.
Tots
Is the page not found coming from Django or is it from some other app that is running? Is it possible that something else is intercepting the request and trying to handle it? I just went through the same basic steps as you and it worked fine.
artran
I download the source code for the book. Code looks the same, but theirs works and mine doesn't. I'm completely perplexed.
Tots
What happens if you stop the runserver and browse to the page? I've been on systems where a local firewall has redirected a request to somewhere else so my app never gets the request.Does the runserver print anything when you browse to it? As a rule the runserver will log all activity.
artran
If i run the example code from the book, it runs and a messages is logged to the console window.If i run my code using the method described above, nothing prints out to the console window. however a response is being sent back to the browser.
Tots
If you are getting a response when the server is stopped then something else is running on port 8000. You could try using a different port: python manage.py runserver 8001Then browse to http://localhost:8001/
artran
A: 

To complete this question - @artran's answer of changing the port

python manage.py runserver 8001

will work.

When python runs the server, it automatically uses port 8000 (hence http://127.0.0.1:8000/). It uses this port as to not tread on the toes of other applications using localhost ports. However, you may still have an application or service running through this port. As such using port 8001 or any other port you may consider free should work.

To repair this in the future, you need to run a program of which can finger all your ports and determine what application is using the :8000 port.

Glycerine