Previous Page Next Page

Starting the Development Server

After you have created the Django project, you should be able to start the development server to test it. The development server is a lightweight web server that is included with the Django project. It lets you develop and test your website without having to deal with all the configuration and management issues of a production web server.

Try It Yourself: Start the Development Server

In this section, you learn how to start the development server.

1.
From a command prompt, change to the root directory for the iFriends project.

2.
Enter the following command to start the development server, as shown in Figure 2.1:

python manage.py runserver

Figure 2.1. Starting the development server from a command line.


By the Way

The manage.py utility is copied into the root of your project by the createproject command discussed earlier in this hour. The manage.py utility first validates the project and reports any errors. If no critical errors are encountered, you are notified that the development sever is running at http://127.0.0.1:8000/.

3.
Verify that the development server is working properly by opening a web browser and entering the following address:

http://127.0.0.1:8000/

If the development server starts properly (and you haven't changed the debug setting), you should see a page similar to the one shown in Figure 2.2.

Figure 2.2. Initial browser view of a Django website.


By the Way

You can tell the development server to use a different port than 8000 if that port is already being used by adding the port to the command line. The following example shows the syntax for configuring the development server to run on port 8008:

manage.py runserver 8008


Did you Know?

To stop the development server, press Ctrl+Break or Ctrl+C.



Previous Page Next Page