-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make types for generic mixins less strict (#168)
- Loading branch information
Showing
4 changed files
with
9 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
from typing import Any, Dict, Optional, Type | ||
from typing import Any, Optional, Type | ||
|
||
from django.views.generic.base import ContextMixin, TemplateResponseMixin, View | ||
|
||
from django.db import models | ||
from django.http import HttpRequest, HttpResponse | ||
|
||
class SingleObjectMixin(ContextMixin): | ||
model: Optional[Type[models.Model]] = ... | ||
queryset: Optional[models.query.QuerySet] = ... | ||
model: Type[models.Model] = ... | ||
queryset: models.query.QuerySet = ... | ||
slug_field: str = ... | ||
context_object_name: Optional[str] = ... | ||
context_object_name: str = ... | ||
slug_url_kwarg: str = ... | ||
pk_url_kwarg: str = ... | ||
query_pk_and_slug: bool = ... | ||
object: models.Model = ... | ||
kwargs: Dict[str, Any] = ... | ||
def get_object(self, queryset: Optional[models.query.QuerySet] = ...) -> models.Model: ... | ||
def get_queryset(self) -> models.query.QuerySet: ... | ||
def get_slug_field(self) -> str: ... | ||
def get_context_object_name(self, obj: Any) -> Optional[str]: ... | ||
|
||
class BaseDetailView(SingleObjectMixin, View): | ||
def render_to_response(self, context: Dict[str, Any], **response_kwargs: Any) -> HttpResponse: ... | ||
def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse: ... | ||
|
||
class SingleObjectTemplateResponseMixin(TemplateResponseMixin): | ||
template_name_field: Optional[str] = ... | ||
template_name_suffix: str = ... | ||
model: Optional[Type[models.Model]] = ... | ||
object: models.Model = ... | ||
|
||
class DetailView(SingleObjectTemplateResponseMixin, BaseDetailView): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters