graphene-django: 404 Not Found after upgrade to 2.3

Just upgraded to 2.3. Then cannot open graphql site anymore. It shows graphiql.js file not found.

Screen Shot 2019-06-19 at 11 10 41 PM Screen Shot 2019-06-19 at 11 14 18 PM

#683 looks similar to my issue, but I can’t pull up the site with what @brandonmbanks did.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@evanheckert @Ouradze @dacevedo12 when running Django with DEBUG=False it will not host static files for you (ref). You will need to run a server to host the static assets or use something like whitenoise to get the python process to host them. Once you have that setup it should work fine.

The reason this changed in v2.3 is that we moved the graphiql javascript bundle into a separate file: https://github.com/graphql-python/graphene-django/pull/508

@danielcwj16 have you added graphene_django to your INSTALLED_APPS list in settings.py? django.contrib.staticfiles also needs to be in that list.

Have you ran python manage.py collectstatic ?

@mmitsui Yes, of course.

# urls.py
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.views.decorators.csrf import csrf_exempt

from graphene_django.views import GraphQLView

urlpatterns = [
    path("__admin/", admin.site.urls), 
    path("gqlendpoint/", csrf_exempt(GraphQLView.as_view(graphiql=True)))
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

And…

# settings.py
import os
...
...
STATIC_URL = "/static/"
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

This is still present in 2.5 😃 You can reproduce it with https://gitlab.com/eclar/django_deploy but only with the production image.

@jkimbo We’re experiencing the same problem. Here’s what our static settings look like image

It works in the local development server but then fails after the app is deployed and served through wsgi

We’ve just pushed out 2.3.2, can you check this is still occurring in that version? I am running 2.3 locally on my machine and I’m having no issues.

Still not works

Could this be related to #508?

Our project pulled in 2.3.0 and we observed the same 404, both FF and Chrome render a blank page at the /graphql/ path, and observed the following printed to our service log:

WARNING:django.request:Not Found: /static/graphene_django/graphiql.js

We’ve rolled back and pinned to 2.2.0 for now.