django-admin and manage.py | Django documentation | Django https://docs.djangoproject.com/en/3.0/ref/django-admin/#runserver

runserver

django-admin runserver [addrport]

Starts a lightweight development Web server on the local machine. By default, the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an IP address and port number explicitly.

If you run this script as a user with normal privileges (recommended), you might not have access to start a port on a low port number. Low port numbers are reserved for the superuser (root).

This server uses the WSGI application object specified by the WSGI_APPLICATION setting.

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

The development server automatically reloads Python code for each request, as needed. You don’t need to restart the server for code changes to take effect. However, some actions like adding files don’t trigger a restart, so you’ll have to restart the server in these cases.

If you’re using Linux or MacOS and install both pywatchman and the Watchman service, kernel signals will be used to autoreload the server (rather than polling file modification timestamps each second). This offers better performance on large projects, reduced response time after code changes, more robust change detection, and a reduction in power usage. Django supports pywatchman 1.2.0 and higher.

Large directories with many files may cause performance issues

When using Watchman with a project that includes large non-Python directories like node_modules, it’s advisable to ignore this directory for optimal performance. See the watchman documentation for information on how to do this.

Watchman timeout

The default timeout of Watchman client is 5 seconds. You can change it by setting the DJANGO_WATCHMAN_TIMEOUT environment variable.

Changed in Django 2.2:

Watchman support replaced support for pyinotify.

When you start the server, and each time you change Python code while the server is running, the system check framework will check your entire Django project for some common errors (see the check command). If any errors are found, they will be printed to standard output.

You can run as many concurrent servers as you want, as long as they’re on separate ports by executing django-admin runserver more than once.

Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or0.0.0.0 or :: (with IPv6 enabled).

You can provide an IPv6 address surrounded by brackets (e.g. [200a::1]:8000). This will automatically enable IPv6 support.

A hostname containing ASCII-only characters can also be used.

If the staticfiles contrib app is enabled (default in new projects) the runserver command will be overridden with its own runserver command.

Logging of each request and response of the server is sent to the django.server logger.

--noreload

Disables the auto-reloader. This means any Python code changes you make while the server is running will not take effect if the particular Python modules have already been loaded into memory.

--nothreading

Disables use of threading in the development server. The server is multithreaded by default.

--ipv6-6

Uses IPv6 for the development server. This changes the default IP address from 127.0.0.1 to ::1.

Examples of using different ports and addresses

Port 8000 on IP address 127.0.0.1:

django-admin runserver

Port 8000 on IP address 1.2.3.4:

django-admin runserver 1.2.3.4:8000

Port 7000 on IP address 127.0.0.1:

django-admin runserver 7000

Port 7000 on IP address 1.2.3.4:

django-admin runserver 1.2.3.4:7000

Port 8000 on IPv6 address ::1:

django-admin runserver -6

Port 7000 on IPv6 address ::1:

django-admin runserver -6 7000

Port 7000 on IPv6 address 2001:0db8:1234:5678::9:

django-admin runserver [2001:0db8:1234:5678::9]:7000

Port 8000 on IPv4 address of host localhost:

django-admin runserver localhost:8000

Port 8000 on IPv6 address of host localhost:

django-admin runserver -6 localhost:8000

最新文章

  1. android——fargment基础
  2. C语言结构体-struct
  3. accept函数
  4. unicode编码、字符的转换和得到汉字的区位码
  5. Sublime Text 3 中文汉化绿色破解特别版下载
  6. ajax的四种type类型
  7. Windows 使用 Visual Studio 编译 caffe
  8. Build 2019 彩蛋
  9. toastr操作完成提示框
  10. 部署的docker image总是太大,怎么办?
  11. win7插着网线开机卡死,拔下网线开机正常
  12. Fish 下报错 Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.
  13. javascript中数组的常用算法深入分析
  14. Linux系统知识汇总
  15. Mac安装Appium的Android环境
  16. 深入分析Spring Boot2,解决 java.lang.ArrayStoreException异常
  17. 最短路径之迪杰斯特拉(Dijkstra)算法
  18. python 中logging的日志封装
  19. 第168天:json对象和字符串的相互转换
  20. 显示游戏FPS帧率的几种计算方式

热门文章

  1. springcloud执行流程理解图
  2. 【Unity游戏开发】SpriteAtlas与AssetBundle最佳食用方案
  3. FPT: Feature Pyramid Transfomer
  4. JS验证三种提示框
  5. java内部类对象使用.this,.new
  6. 智能BPOS小票模板字体的使用
  7. ZooKeeper集群“脑裂”
  8. UNraid学习随手记:显示主板、CPU传感器温度
  9. [Abp]Abp 新手入门随记
  10. R语言学习笔记-Corrplot相关性分析