In this Django tutorial, we are going to learn how to run Django's development server. Django ships with a lightweight development server that allows use to simply run our project via our computer to test the project. Do not use this server in production because first off it is not designed for production and it is not secure. Servers go through a rigorous testing for security and performance testing and the folks at Django who created this server did not perform this test for the simple reason that it is only to be used on a local computer.
How To Run The Server
Now let's run the server and check out the website that we have created. To fire up the server we add a simple command into the terminal that will start the server. Make sure you are in the directory that contains manage.py and enter the following command python manage.py runserver the server will start up and run some system checks if everything is good to go you can see your website at http://127.0.0.1:8000/
What Your Terminal Should look like
(lpt) Thomass-MBP:lpt Tommy$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
July 13, 2016 - 19:00:37
Django version 1.9.7, using settings 'lpt.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
When you visit http://127.0.0.1:8000/ you should see the following website.
Django Welcome Screen
Now if this did not work for you depending on your error message you may have something running on the port Django is trying to use for the server. We can change the port using this command python manage.py runserver 127.0.0.1:8001 just changing the port by one may help. The numbers on the left side of the colon are the ip address which can be changed also and the numbers on the right side of the colon is the port. I suggest changing the port first most of the time that is the issue.
Stopping and Starting The Server
The development server will refresh for most changes done while the server is running so normally. We do not need to stop and start for each change. When files are added then we need to stop the server. Then rerun the server for those changes to take effect. To stop the server press control + c to kill the server. To start the server we need to enter the same command we used the first time to start the server.
Conclusion
In this Django tutorial, we learned how to run Django's development server. We also looked at some ways to work around issues that may come up. Remember this server is not designed for production. Django needs a secure server and that server has to have the required software to run Python files. If you have any questions or issues getting the development server running leave a comment below.