Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem importing module for GRAPHENE setting 'SCHEMA' in Django 2.2

I am new to django(installed version 2.2 in my virtualenv) and graphql. I tried to follow the instructions for setting up graphql in django from the following site

https://docs.graphene-python.org/projects/django/en/latest/installation/

When I try to run the server with the url http://127.0.0.1:8000/graphql/

I get the following error.

ImportError at /graphql/
Could not import 'django_root.schema.schema' for Graphene setting 
'SCHEMA'. ModuleNotFoundError: No module named 'django_root'.

I followed the instructions carefully but I am unable to get this right. Please help. I checked similar questions but it didn't help.

Edit: I tried the following

'SCHEMA': 'folder_with_setting.py_file.schema.schema'

'SCHEMA': 'folder_with_manage.py_file.schema.schema'

'SCHEMA': 'folder_with_manage.py_file.folder_with_settings.py_file.schema.schema'

'SCHEMA': 'folder_with_manage.py_file/folder_with_settings.py_file.schema.schema'

and many other combinations. It's not working.

like image 526
ShashankAC Avatar asked Nov 24 '25 02:11

ShashankAC


2 Answers

You should use the right path of your project in settings.py

GRAPHENE = {
    'SCHEMA': 'django_root.schema.schema'  #  change your path
}

Where path.schema.schema is the location of the Schema object in your Django project.

like image 194
everfight Avatar answered Nov 25 '25 15:11

everfight


'SCHEMA': 'addyourappnamehere.schema.schema',

faced the same error this worked i added the app name eg:

'SCHEMA': 'auth.schema.schema',
like image 43
fuse Avatar answered Nov 25 '25 16:11

fuse