|
4 | 4 |
|
5 | 5 | from django.db.models import Model, QuerySet |
6 | 6 |
|
7 | | -from django_unicorn.components import QueryType, UnicornField, UnicornView |
| 7 | +from django_unicorn.components import UnicornField, UnicornView |
| 8 | +from django_unicorn.components.typing import QuerySetType |
8 | 9 | from django_unicorn.decorators import timed |
9 | 10 | from django_unicorn.utils import get_type_hints |
10 | 11 |
|
@@ -138,21 +139,21 @@ def _is_queryset(field, type_hint, value): |
138 | 139 |
|
139 | 140 | return ( |
140 | 141 | isinstance(field, QuerySet) |
141 | | - or (type_hint and get_origin(type_hint) is QueryType) |
| 142 | + or (type_hint and get_origin(type_hint) is QuerySetType) |
142 | 143 | ) and isinstance(value, list) |
143 | 144 |
|
144 | 145 |
|
145 | 146 | def _create_queryset(field, type_hint, value) -> QuerySet: |
146 | 147 | """ |
147 | | - Create a queryset based on the `value`. If needed, the queryset will be created based on the `QueryType`. |
| 148 | + Create a queryset based on the `value`. If needed, the queryset will be created based on the `QuerySetType`. |
148 | 149 |
|
149 | 150 | For example, all of these ways fields are equivalent: |
150 | 151 |
|
151 | 152 | ``` |
152 | 153 | class TestComponent(UnicornView): |
153 | | - queryset_with_empty_list: QueryType[SomeModel] = [] |
154 | | - queryset_with_none: QueryType[SomeModel] = None |
155 | | - queryset_with_empty_queryset: QueryType[SomeModel] = SomeModel.objects.none() |
| 154 | + queryset_with_empty_list: QuerySetType[SomeModel] = [] |
| 155 | + queryset_with_none: QuerySetType[SomeModel] = None |
| 156 | + queryset_with_empty_queryset: QuerySetType[SomeModel] = SomeModel.objects.none() |
156 | 157 | queryset_with_no_typehint = SomeModel.objects.none() |
157 | 158 | ``` |
158 | 159 |
|
|
0 commit comments