Django Blog #3: Running the Server

by Alex
Django Blog #3: Running the Server
Django has a web server which you need for quick code verification. It saves you the trouble of setting up a full working solution. When it starts up, the server keeps checking for changes in the code and reboots on its own. But some things it doesn’t notice: such as new files in the project. In this case, you need to restart the server manually. You can start the server with the following command in the root directory:

python manage.py runserver

The following lines will appear:

Performing system checks...

System check identified no issues (0 silenced).
November 16, 2019 - 15:20:27
Django version 2.0.5, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

Now you need to open https://127.0.0.1:8000/ in your browser. The page will inform you that the project is working. As in the following screenshot:Django Blog #3: Running the Server This image tells you that Django is working. If you look at the console, you can see a GET request from the browser:

[16/Nov/2019 15:22:45] "GET / HTTP/1.1" 200 16348

Each HTTP request is logged separately. The command line will display any errors that appear in the process. You can start the server on a different port or use a different configuration file with these commands:

python manage.py runserver 127.0.0.1:8001 --settings=mysite.settings

When working with different environments that require different settings, you can create several files for each of them.

This server should only be used for development and not for full use. To deploy Django in a production environment, you need to run it as a WSGI application using a real tool: Apache, Gunicorn, or uWSGI.

Related Posts

LEAVE A COMMENT