📅  最后修改于: 2023-12-03 14:40:46.594000             🧑  作者: Mango
Django Runserver is a command-line tool used to test and run Django projects locally. It provides a lightweight development web server that supports static and dynamic content, and supports a number of useful features such as code reloading and error reporting.
To use Django Runserver, simply navigate to the root directory of your Django project in the terminal/command prompt and run the following command:
python manage.py runserver
This starts the development server on the default port of 8000. You can access your Django project in your browser by visiting http://localhost:8000.
To run Django Runserver on a different port, simply specify the desired port number after the command:
python manage.py runserver 8080
This would start the development server on port 8080, and you could access your Django project in your browser by visiting http://localhost:8080.
By default, Django Runserver automatically reloads your code whenever changes are made. This feature can be disabled by passing the --noreload option:
python manage.py runserver --noreload
By default, Django Runserver displays only basic error messages. To display more detailed error messages, pass the --traceback option:
python manage.py runserver --traceback
Django Runserver is a powerful tool for testing and developing Django projects. With just a few simple commands, you can start a local development server, change the port number, enable code reloading, and display detailed error messages. This makes it easy to test your code and debug any issues that arise during development.