[Fixed]-AttributeError: type object 'User' has no attribute 'name'

28👍

This is a cryptic error that happens when Django Model classes are accidentally used in code instead of graphene Type classes. For example, make sure that your query is something like

user = graphene.Field(UserType)

instead of

user = graphene.Field(User)

0👍

As suggested by your error, Django’s default User model does not have a field called name.

Instead, it has two similar fields, first_name, and last_name.

If you would like to use the combination of the two, use the get_full_name() method.

👤meshy

Leave a comment