Forums

WSGI error unexpected indent

wsgi.py in /home/username/mysite/mysite

contents of wsgi.py:

# +++++++++++ DJANGO +++++++++++
# To use your own django app use code like this:

    import os
    import sys

    from django.core.wsgi import get_wsgi_application

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

    application = get_wsgi_application()

Error:

Error running WSGI application 2019-01-08 16:30:50,167: File "/var/www/username_pythonanywhere_com_wsgi.py", line 7 +++++++++++ DJANGO +++++++++++ 2019-01-08 16:30:50,168: 2019-01-08 16:30:50,168: ^ 2019-01-08 16:30:50,168: 2019-01-08 16:30:50,168: IndentationError: unexpected indent

Any ideas what I've done wrong?

Thanks, Richard

I had this error before when I copied my file in the browser text editor. It was because of changing the intern line breaking (DOS style) and mixed with Linux ones. If you edit the file after it can occur errors like these.

I don't know if you understand what I mean, try to upload the file instead of copying in the browser text editor. If that was what you did.

It looks like you've indented the lines of code -- that is, everything from import os downwards. They should be unindented.

Interesting. I decided to start fresh and am now in the middle of setting up a flask app which seems to be going well so far. Thanks for your help.