Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

680
Views
What does TypeError, __init__() missing 1 required positional argument: 'get_response' mean in python?

I'm following the graphql python tutorial at https://www.howtographql.com/graphql-python/4-authentication/. It worked fine for the first 3 sections, but in the Authentication section I've run into this problem.

I am learning python, don't know Django or graphql, so it's a lot to digest all at once, but it was going ok until now. Also not sure what relevant bits to include here.

I followed all the instructions. When I go to my local project site at localhost:8000/graphql/, I get

TypeError at /graphql/
__init__() missing 1 required positional argument: 'get_response'

Here is the relevant snippet of my settings.py:

MIDDLEWARE = [
    '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',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
]

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

AUTHENTICATION_BACKENDS = [
    'graphql_jwt.backends.JSONWebTokenBackend',
    'django.contrib.auth.backends.ModelBackend',
]

I also did import graphql_jwt in my main schema.py

Here is some kind of stack trace

Environment:


Request Method: GET
Request URL: http://localhost:8000/graphql/

Django Version: 2.1.4
Python Version: 3.7.4
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'graphene_django',
 'links']
Installed Middleware:
['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',
 'django.contrib.auth.middleware.AuthenticationMiddleware']



Traceback:

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\django\core\handlers\exception.py" in inner
  34.             response = get_response(request)

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\django\core\handlers\base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\django\core\handlers\base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
  54.         return view_func(*args, **kwargs)

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\django\views\generic\base.py" in view
  62.             self = cls(**initkwargs)

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\graphene_django\views.py" in __init__
  88.             self.middleware = list(instantiate_middleware(middleware))

File "C:\Users\e79909\projects\python\graphql-python\venv\lib\site-packages\graphene_django\views.py" in instantiate_middleware
  48.             yield middleware()

Exception Type: TypeError at /graphql/
Exception Value: __init__() missing 1 required positional argument: 'get_response'
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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',
]
over 4 years ago · Santiago Trujillo Report

0

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!