Work with custom user
alfredogama opened this issue · 2 comments
Prerequisites
- Is it a bug?
- Is it a new feature?
- Is it a a question?
- Can you reproduce the problem?
- Are you running the latest version?
- Did you check for similar issues?
- Did you perform a cursory search?
For more information, see the CONTRIBUTING guide.
Description
Hello Pedro,
I have a custom user, now the username is the email, but Im getting the error 'Meta.fields' must not contain non-model field names: username, I follow your recommendations but no success. I reproduced your demo here: https://github.com/alfredogama/graphql-with-auth.
Steps to Reproduce
1 clone your demo sample
2 use a custom User
3 start the graphi (http://127.0.0.1:8000/graphql)
Expected behavior
Open the Graphi
Actual behavior
I got an error:
TypeError at /graphql
'Meta.fields' must not contain non-model field names: username
Requirements
aniso8601==7.0.0
asgiref==3.3.1
Django==3.1.4
django-filter==2.4.0
django-graphql-auth==0.3.15
django-graphql-jwt==0.3.0
graphene==2.1.8
graphene-django==2.13.0
graphql-core==2.3.2
graphql-relay==2.0.1
promise==2.3
PyJWT==1.7.1
pytz==2020.4
Rx==1.6.1
singledispatch==3.4.0.3
six==1.15.0
sqlparse==0.4.1
text-unidecode==1.3
Unidecode==1.1.1
@PedroBern I'm getting this same error too. Am I missing something?
Try GRAPHQL_AUTH
config on settings.py.
Example:
GRAPHQL_AUTH = {
'LOGIN_ALLOWED_FIELDS': ['email'], # use email field for login
'REGISTER_MUTATION_FIELDS': ['email', 'first_name'], # fields for register mutation
'USERNAME_FIELD' : ['email'],
# the next option should solve your problems, tell 'django-filter' which fields to filter
'USER_NODE_FILTER_FIELDS': {
"email": ["exact",],
"is_active": ["exact"],
"status__archived": ["exact"],
"status__verified": ["exact"],
"status__secondary_email": ["exact"],
}
}