Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django-stubs/apps/registry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Apps:
def get_app_config(self, app_label: str) -> AppConfig: ...
# it's not possible to support it in plugin properly now
def get_models(self, include_auto_created: bool = ..., include_swapped: bool = ...) -> List[Type[Model]]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Any]: ...
def get_model(self, app_label: str, model_name: Optional[str] = ..., require_ready: bool = ...) -> Type[Model]: ...
def register_model(self, app_label: str, model: Type[Model]) -> None: ...
def is_installed(self, app_name: str) -> bool: ...
def get_containing_app_config(self, object_name: str) -> Optional[AppConfig]: ...
Expand Down
15 changes: 15 additions & 0 deletions tests/typecheck/apps/test_registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- case: apps_get_model
main: |
from django.apps.registry import apps

model = apps.get_model("myapp", "MyUser")
reveal_type(model) # N: Revealed type is "Type[django.db.models.base.Model]"
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from django.db import models
class MyUser(models.Model):
pass