[Solved]-What does TypeError, __init__() missing 1 required positional argument: 'get_response' mean in python?

17πŸ‘

βœ…

Ok, I just found it.

GRAPHENE = {
    'SCHEMA': 'hackernews.schema.schema',
    'MIDDLEWARES': ['graphql_jwt.middleware.JSONWebTokenMiddleware'],
}

Notice the S. It needs to be 'MIDDLEWARES', not 'MIDDLEWARE'.

Found the solution on this GitHub issue

Also, according to this comment on the same issue, you should add 'graphql_jwt.middleware.JSONWebTokenMiddleware' to the MIDDLEWARE list (the one with all the Django middleware).

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'graphql_jwt.middleware.JSONWebTokenMiddleware', ### <---Add this line
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
πŸ‘€tbrlpld

0πŸ‘

upgrade django-graphql-jwt to 0.3.4 (or higher) from the tutorial’s 0.1.5

πŸ‘€ultravires

0πŸ‘

Faced this issue when we moved from Django 2.2 to Django 4.0.5 version.
Updated the DRF version from 3.12.0 to 3.14.0 to fix this issue.

pip install djangorestframework==3.14.0

Leave a comment