How can I tell whether my Django application is running on development server or not?

后端 未结 13 1606
别跟我提以往
别跟我提以往 2020-12-05 03:37

How can I be certain that my application is running on development server or not? I suppose I could check value of settings.DEBUG and assume if DEBUG

13条回答
  •  悲哀的现实
    2020-12-05 04:30

    You could check request.META["SERVER_SOFTWARE"] value:

    dev_servers = ["WSGIServer", "Werkzeug"]
    if any(server in request.META["SERVER_SOFTWARE"] for server in dev_servers):
        print("is local")
    

提交回复
热议问题