Django provides a built-in lightweight web server that helps you preview your application during development. It automatically reloads when you make changes, making it ideal for rapid testing.
manage.py utility.Before running the server, make sure you're in the directory that contains your manage.py file.
// Navigate to the Django project directory
cd myproject
Replace myproject with the actual name of your project folder.
Once inside the project directory, execute the following command to start the server:
// Start the Django development server
python manage.py runserver
By default, the server runs at http://127.0.0.1:8000/.
After running the command, you should see output similar to this:
// Console output indicating the server is running
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
This confirms that the server is running successfully.
To stop the development server, press Ctrl + C in the terminal.
Change the port number below and understand how Django binds the server to different ports.
// Run the server on a custom port
python manage.py runserver 8080
Simulated Terminal Output:
0.0.0.0:8000 to expose the server on your local network.