pythondjangocorsdjango-cors-headers

No module found 'corsheaders' django/heroku deploy


None of the other answers have worked for me. Ive done pipenv install django-cors-headers, pipenv install psycopg2-binary, etc. until my fingers have blisters to no avail...

This is going to be a bit long if you don't mind looking; thanks in advance...

*settings.py*

# Application definition

INSTALLED_APPS = [
    'corsheaders',
    'rest_framework',
    'rest_framework.authtoken',
    'quizzes',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles'
] 


MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

This is the Pipfile on the proper level...

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[requires]
python_version = "3.6"

[packages]
python-decouple = "*"
"psycopg2" = "*"
django-dotenv = "*"
gunicorn = "*"
whitenoise = "*"
dj-database-url = "*"
djangorestframework = "*"
django = "*"
django-cors-headers = "*"
"psycopg2-binary" = "*"

[dev-packages]

But I am still getting traceback line 17 from ./manage.py and ultimately No module named 'corsheaders'... I've uninstalled/reinstalled and everything. Anyone got any ideas?


Solution

  • I had the same problem and I noticed that I forgot to add this:

    django-cors-headers==3.11.0
    

    to my requirements.txt