Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 is True then it's running on development server, but I'd prefer to know for sure than relying on convention.

like image 427
Imran Avatar asked Aug 18 '09 04:08

Imran


People also ask

What server does Django use for development?

Django provides a simple WSGI server as a dev server.

How do I know if Django is running?

To verify the Django project, make sure your virtual environment is activated, then start Django's development server using the command python manage.py runserver . The server runs on the default port 8000, and you see output like the following output in the terminal window: Performing system checks...

Is Django web server or application server?

Django, being a web framework, needs a web server in order to operate. And since most web servers don't natively speak Python, we need an interface to make that communication happen. Django currently supports two interfaces: WSGI and ASGI.


1 Answers

I put the following in my settings.py to distinguish between the standard dev server and production:

import sys RUNNING_DEVSERVER = (len(sys.argv) > 1 and sys.argv[1] == 'runserver') 

This also relies on convention, however.

(Amended per Daniel Magnusson's comment)

like image 85
Aryeh Leib Taurog Avatar answered Oct 11 '22 08:10

Aryeh Leib Taurog