To run the Django development server, follow these steps:
Install Django:
Make sure you have Django installed. If you haven't installed it yet, you can use pip
, the Python package manager, to install it:
bashpip install Django
Create a Django Project: Create a new Django project using the following command:
bashdjango-admin startproject projectname
Replace "projectname" with the desired name for your project.
Navigate to the Project Directory: Change into the project directory using:
bashcd projectname
Run the Development Server: Once inside the project directory, you can start the development server with the following command:
bashpython manage.py runserver
By default, the development server will run on http://127.0.0.1:8000/
. You can access it through your web browser.
If you want to specify a different host or port, you can do so by providing the host and port as arguments:
bashpython manage.py runserver 0.0.0.0:8080
This command would make the development server accessible from any IP address on port 8080.
Access the Development Server:
Open your web browser and go to http://127.0.0.1:8000/
or the custom host and port you specified. You should see the default Django welcome page.
Stop the Development Server:
To stop the development server, you can press Ctrl+C
in the terminal where it's running. Django will then stop the server, and you can return to the command line.
Remember, the development server is not suitable for production use. It's meant for development and debugging purposes. For a production environment, you should use a production-ready server like Gunicorn or uWSGI behind a web server like Nginx or Apache.