Skip to content

Commit

Permalink
add cache_name for django 5.1 (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile authored Sep 10, 2024
1 parent 205ea3b commit 0a3cb4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion django-stubs/contrib/contenttypes/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class GenericForeignKey(FieldCacheMixin):
def get_filter_kwargs_for_object(self, obj: Model) -> dict[str, ContentType | None]: ...
def get_forward_related_filter(self, obj: Model) -> dict[str, int]: ...
def check(self, **kwargs: Any) -> list[CheckMessage]: ...
def get_cache_name(self) -> str: ...
def get_content_type(
self, obj: Model | None = ..., id: int | None = ..., using: str | None = ..., model: type[Model] | None = ...
) -> ContentType: ...
Expand Down
3 changes: 3 additions & 0 deletions django-stubs/db/models/fields/mixins.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from typing import Any

from django.db.models.base import Model
from django.utils.functional import cached_property

NOT_PROVIDED: Any

class FieldCacheMixin:
def get_cache_name(self) -> str: ...
@cached_property
def cache_name(self) -> str: ...
def get_cached_value(self, instance: Model, default: Any = ...) -> Model | None: ...
def is_cached(self, instance: Model) -> bool: ...
def set_cached_value(self, instance: Model, value: Model | None) -> None: ...
Expand Down

0 comments on commit 0a3cb4a

Please sign in to comment.