App's wsgi file

To run Gunicorn need to use this command line:

$ gunicorn myproject.wsgi

But my question is: where to find the application wsgi object?

At setting.py I have:

WSGI_APPLICATION = 'callservices.wsgi.application'

But I can not find that file.

At /ProyectName/app/ there is wsgi.py file. What is this?

Could you please help me?

If you look in your wsgi.py file, you’ll find a line that looks something like this:
application = get_wsgi_application()

When the wsgi.py file is imported, the application object gets created from that get_wsgi_application function.

1 Like

Thanks.

But what is myproyect.wsgi? I have to pass that file (myproyect.wsgi) to gunicorn

gunicorn myproject.wsgi

in wsgi.py there is

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'callservices.settings')

application = get_wsgi_application()

See the Deployment docs for more details, but briefly, your “application container” (uwsgi / gunicorn) needs to know how to run your Django application. It does that by using an object named “application” defined in the file you pass to it.

So you’re passing a wsgi file to the container, the container can run that file to get the application object it needs to actually run your application.

(There’s a little bit more to it than that, but this should give you a general idea of its purpose.)

1 Like