Skip to content

Can't import RelatedManager #765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oren0e opened this issue Dec 7, 2021 · 6 comments
Closed

Can't import RelatedManager #765

oren0e opened this issue Dec 7, 2021 · 6 comments
Labels
question Further information is requested

Comments

@oren0e
Copy link

oren0e commented Dec 7, 2021

If I write:

if typing.TYPE_CHECKING:
    from django_stubs.db.models.manager import RelatedManager

I get "import could not be resolved". It seems that the .db.models.manager part is not "seen".. (I also can't "go to definition" there). Any ideas?

@intgr intgr added the question Further information is requested label Nov 8, 2022
@intgr
Copy link
Collaborator

intgr commented Nov 8, 2022

This should work:

if typing.TYPE_CHECKING:
    from django.db.models.manager import RelatedManager

@sobolevn
Copy link
Member

sobolevn commented Nov 8, 2022

Please, reopen if it does not.

@sobolevn sobolevn closed this as completed Nov 8, 2022
@tylerlaprade
Copy link

@sobolevn, this worked fine for me in 4.2.6, but is now broken after upgrading to 4.2.7
image

@intgr
Copy link
Collaborator

intgr commented Dec 13, 2023

@tylerlaprade Yes, this changed in 4.2.7, it was covered in the release notes:

  • If you previously imported RelatedManager or ManyRelatedManager, update those to django-stubs-ext:
    from django_stubs_ext.db.models.manager import ManyRelatedManager, RelatedManager

But we have another issue #1868 that suggests this may not work in Pylance/pyright. If you could help us troubleshoot it, it would be appreciated.

@intgr
Copy link
Collaborator

intgr commented Dec 13, 2023

In any case, please report back if that works for you or not.

@tylerlaprade
Copy link

Oh nice, from django_stubs_ext.db.models.manager import RelatedManager actually works perfectly for me in Pylance/pyright!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

4 participants