|
| 1 | +from .registry import models_registry, register_model # noqa Create the registry first |
1 | 2 | from . import ( |
2 | | - preflight, # noqa |
3 | | -) |
4 | | -from .aggregates import ( |
5 | | - Aggregate, |
6 | | - Avg, |
7 | | - Count, |
8 | | - Max, |
9 | | - Min, |
10 | | - StdDev, |
11 | | - Sum, |
12 | | - Variance, |
13 | | -) |
14 | | -from .constraints import ( |
15 | | - BaseConstraint, |
16 | | - CheckConstraint, |
17 | | - Deferrable, |
18 | | - UniqueConstraint, |
19 | | -) |
20 | | -from .db import ( |
21 | | - DatabaseError, |
22 | | - DataError, |
23 | | - Error, |
24 | | - IntegrityError, |
25 | | - InterfaceError, |
26 | | - InternalError, |
27 | | - NotSupportedError, |
28 | | - OperationalError, |
29 | | - ProgrammingError, |
30 | | - db_connection, |
31 | | -) |
32 | | -from .deletion import ( |
33 | | - CASCADE, |
34 | | - DO_NOTHING, |
35 | | - PROTECT, |
36 | | - RESTRICT, |
37 | | - SET, |
38 | | - SET_DEFAULT, |
39 | | - SET_NULL, |
40 | | - ProtectedError, |
41 | | - RestrictedError, |
42 | | -) |
43 | | -from .enums import Choices, IntegerChoices, TextChoices |
44 | | -from .expressions import ( |
45 | | - Case, |
46 | | - Exists, |
47 | | - F, |
48 | | - OuterRef, |
49 | | - Subquery, |
50 | | - Value, |
51 | | - When, |
52 | | - Window, |
| 3 | + preflight, # noqa Imported for side effects (registers preflight checks) |
53 | 4 | ) |
| 5 | + |
| 6 | +# Imports that would create circular imports if sorted |
| 7 | +from .base import Model |
| 8 | +from .constraints import CheckConstraint, UniqueConstraint |
| 9 | +from .db import IntegrityError, db_connection |
| 10 | +from .deletion import CASCADE, DO_NOTHING, PROTECT, RESTRICT, SET, SET_DEFAULT, SET_NULL |
| 11 | +from .enums import IntegerChoices, TextChoices |
54 | 12 | from .fields import ( |
55 | 13 | BigIntegerField, |
56 | 14 | BinaryField, |
|
75 | 33 | UUIDField, |
76 | 34 | ) |
77 | 35 | from .fields.json import JSONField |
78 | | -from .indexes import Index |
79 | | -from .query import Prefetch, QuerySet, prefetch_related_objects |
80 | | -from .query_utils import FilteredRelation, Q |
81 | | -from .registry import models_registry, register_model |
82 | | - |
83 | | -# Imports that would create circular imports if sorted |
84 | | -from .base import Model # isort:skip |
85 | | -from .options import Options # isort:skip |
86 | | -from .fields.related import ( # isort:skip |
| 36 | +from .fields.related import ( |
87 | 37 | ForeignKey, |
88 | 38 | ManyToManyField, |
89 | 39 | ) |
| 40 | +from .indexes import Index |
| 41 | +from .options import Options |
| 42 | +from .query import QuerySet |
| 43 | +from .query_utils import Q |
90 | 44 |
|
91 | | - |
| 45 | +# This module exports the user-facing API for defining model classes, |
| 46 | +# with a secondary focus on the most common query utilities like Q. |
| 47 | +# Advanced query-time features (aggregates, expressions, etc.) should be |
| 48 | +# imported from their specific modules (e.g., plain.models.aggregates). |
92 | 49 | __all__ = [ |
93 | | - # From aggregates |
94 | | - "Aggregate", |
95 | | - "Avg", |
96 | | - "Count", |
97 | | - "Max", |
98 | | - "Min", |
99 | | - "StdDev", |
100 | | - "Sum", |
101 | | - "Variance", |
102 | 50 | # From constraints |
103 | | - "BaseConstraint", |
104 | 51 | "CheckConstraint", |
105 | | - "Deferrable", |
106 | 52 | "UniqueConstraint", |
107 | 53 | # From enums |
108 | | - "Choices", |
109 | 54 | "IntegerChoices", |
110 | 55 | "TextChoices", |
111 | 56 | # From fields |
|
130 | 75 | "TimeField", |
131 | 76 | "URLField", |
132 | 77 | "UUIDField", |
| 78 | + # From fields.json |
| 79 | + "JSONField", |
133 | 80 | # From indexes |
134 | 81 | "Index", |
135 | 82 | # From deletion |
|
140 | 87 | "SET", |
141 | 88 | "SET_DEFAULT", |
142 | 89 | "SET_NULL", |
143 | | - "ProtectedError", |
144 | | - "RestrictedError", |
145 | | - # From expressions |
146 | | - "Case", |
147 | | - "Exists", |
148 | | - "F", |
149 | | - "OuterRef", |
150 | | - "Subquery", |
151 | | - "Value", |
152 | | - "When", |
153 | | - "Window", |
154 | | - # From fields.json |
155 | | - "JSONField", |
156 | 90 | # From options |
157 | 91 | "Options", |
158 | 92 | # From query |
159 | | - "Prefetch", |
160 | 93 | "QuerySet", |
161 | | - "prefetch_related_objects", |
162 | 94 | # From query_utils |
163 | | - "FilteredRelation", |
164 | 95 | "Q", |
165 | 96 | # From base |
166 | 97 | "Model", |
|
169 | 100 | "ManyToManyField", |
170 | 101 | # From db |
171 | 102 | "db_connection", |
172 | | - "DatabaseError", |
173 | 103 | "IntegrityError", |
174 | | - "InternalError", |
175 | | - "ProgrammingError", |
176 | | - "DataError", |
177 | | - "NotSupportedError", |
178 | | - "Error", |
179 | | - "InterfaceError", |
180 | | - "OperationalError", |
181 | 104 | # From registry |
182 | 105 | "register_model", |
183 | 106 | "models_registry", |
|
0 commit comments