Neovim for Django: metaclasses are not recognized

2.8k Views Asked by At

Image of Error Message in Neovim

I have been trying to configure my neovim for django development and everything seems fine except for this issue I am having with fields in metaclasses. the image provided gives a snapshot and the code is as follows:

class UserSerializer(serializers.ModelSerializer):                              
  snippets = serializers.PrimaryKeyRelatedField(many=True, queryset=Snippet.objects.all())

the linting error indicates that it cannot access member objects for the Snippet class.

I am using coc-pyright with default settings. I tried playing around with the settings by enabling pylint and installing pylint-django in my project as a dev dependency but that was unable to resolve the issue. How would I fix this issue? Does anyone have a recommended setup for Django development in nvim?

1

There are 1 best solutions below

5
On

I am using a similar setup, and I could resolve the issue you described by installing the django-stubs package.