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

后端 未结 13 1570
别跟我提以往
别跟我提以往 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:34

    If you want to switch your settings files automatically dependent on the runtime environment you could just use something that differs in environ, e.g.

    from os import environ
    if environ.get('_', ''): 
        print "This is dev - not Apache mod_wsgi"         
    

提交回复
热议问题