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

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

    I use:

    DEV_SERVERS = [
        'mymachine.local',
    ]
    
    DEVELOPMENT = platform.node() in DEV_SERVERS
    

    which requires paying attention to what is returned by .node() on your machines. It's important that the default be non-development so that you don't accidentally expose sensitive development information.

    You could also look into more complicated ways of uniquely identifying computers.

    0 讨论(0)
提交回复
热议问题