django-display-ids 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_display_ids/models.py +4 -1
- django_display_ids/resolver.py +10 -1
- {django_display_ids-0.3.0.dist-info → django_display_ids-0.3.1.dist-info}/METADATA +2 -2
- {django_display_ids-0.3.0.dist-info → django_display_ids-0.3.1.dist-info}/RECORD +5 -5
- {django_display_ids-0.3.0.dist-info → django_display_ids-0.3.1.dist-info}/WHEEL +0 -0
django_display_ids/models.py
CHANGED
|
@@ -125,12 +125,15 @@ class DisplayIDMixin(models.Model):
|
|
|
125
125
|
"""Generate the display ID for this instance.
|
|
126
126
|
|
|
127
127
|
Returns:
|
|
128
|
-
Display ID in format {prefix}_{base62(uuid)}, or None if no prefix
|
|
128
|
+
Display ID in format {prefix}_{base62(uuid)}, or None if no prefix
|
|
129
|
+
or if the UUID field is None (e.g., unsaved instance).
|
|
129
130
|
"""
|
|
130
131
|
prefix = self.get_display_id_prefix()
|
|
131
132
|
if prefix is None:
|
|
132
133
|
return None
|
|
133
134
|
uuid_value = getattr(self, self._get_uuid_field())
|
|
135
|
+
if uuid_value is None:
|
|
136
|
+
return None
|
|
134
137
|
return encode_display_id(prefix, uuid_value)
|
|
135
138
|
|
|
136
139
|
# Django admin display configuration
|
django_display_ids/resolver.py
CHANGED
|
@@ -51,12 +51,21 @@ def resolve_object(
|
|
|
51
51
|
UnknownPrefixError: If display ID prefix doesn't match expected.
|
|
52
52
|
ObjectNotFoundError: If no matching object exists.
|
|
53
53
|
AmbiguousIdentifierError: If multiple objects match (slug lookup).
|
|
54
|
+
TypeError: If queryset is not for the specified model.
|
|
54
55
|
"""
|
|
55
56
|
# Parse the identifier to determine type
|
|
56
57
|
result = parse_identifier(value, strategies, expected_prefix=prefix)
|
|
57
58
|
|
|
58
59
|
# Get the base queryset
|
|
59
|
-
|
|
60
|
+
if queryset is not None:
|
|
61
|
+
if queryset.model is not model:
|
|
62
|
+
raise TypeError(
|
|
63
|
+
f"queryset must be for {model.__name__}, "
|
|
64
|
+
f"got queryset for {queryset.model.__name__}"
|
|
65
|
+
)
|
|
66
|
+
qs: QuerySet[M] = queryset
|
|
67
|
+
else:
|
|
68
|
+
qs = model._default_manager.all()
|
|
60
69
|
|
|
61
70
|
# Build the lookup based on strategy
|
|
62
71
|
lookup: dict[str, Any]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: django-display-ids
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Stripe-like prefixed IDs for Django. Works with existing UUIDs — no schema changes.
|
|
5
5
|
Keywords: django,stripe,uuid,base62,prefixed-id,drf,shortuuid,nanoid,ulid
|
|
6
6
|
License: MIT
|
|
@@ -117,7 +117,7 @@ Full documentation at [django-display-ids.readthedocs.io](https://django-display
|
|
|
117
117
|
|
|
118
118
|
## Contributing
|
|
119
119
|
|
|
120
|
-
See the [contributing guide](https://django-display-ids.readthedocs.io/en/latest/contributing
|
|
120
|
+
See the [contributing guide](https://django-display-ids.readthedocs.io/en/latest/contributing/).
|
|
121
121
|
|
|
122
122
|
## Related Projects
|
|
123
123
|
|
|
@@ -12,14 +12,14 @@ django_display_ids/encoding.py,sha256=csIwUZaQKSOLwRU6-DWGTNGvSxmroyK0Yt7TBCo0AF
|
|
|
12
12
|
django_display_ids/examples.py,sha256=gap5NNPTmE7B5uxiYKoMoK8G-OEtL1Ek0W039l6oJ9I,2689
|
|
13
13
|
django_display_ids/exceptions.py,sha256=nmyRfpsqVvz226Zcu_QANwr8MudbfoX09mAgOCwuPuQ,3022
|
|
14
14
|
django_display_ids/managers.py,sha256=PymcK4BZL6UsUOtoloHP34MCRNmvNHSKEcOImhZxGag,9779
|
|
15
|
-
django_display_ids/models.py,sha256=
|
|
15
|
+
django_display_ids/models.py,sha256=XI73N4bvxy1Pr2oHeTaJP3uq3huyCX67CFZ2T8mefsA,4317
|
|
16
16
|
django_display_ids/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
-
django_display_ids/resolver.py,sha256=
|
|
17
|
+
django_display_ids/resolver.py,sha256=ZlDVoxX0PmVf0MSwPyiNNwQVzdqJGDGE8fm2iyV7QjE,2848
|
|
18
18
|
django_display_ids/strategies.py,sha256=Rq00-AW_FB8-K04u2oBK5J6kPiYgsE3TdYlLyK_zro0,4436
|
|
19
19
|
django_display_ids/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
django_display_ids/templatetags/display_ids.py,sha256=4KHE8r8mgSKb7LgIuXJaJB_3UGrzRZvTdLqSCYQtb5I,1157
|
|
21
21
|
django_display_ids/typing.py,sha256=2O3kT7XKkiE7WI9A5KkILPM-Zi7-zCy5gVvXQL_J2mI,478
|
|
22
22
|
django_display_ids/views.py,sha256=-y_Zwo4QLU0lPRPjABpijsze5vsG0CBvJtrVwVtuLwM,5127
|
|
23
|
-
django_display_ids-0.3.
|
|
24
|
-
django_display_ids-0.3.
|
|
25
|
-
django_display_ids-0.3.
|
|
23
|
+
django_display_ids-0.3.1.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
24
|
+
django_display_ids-0.3.1.dist-info/METADATA,sha256=eKOjG80Rb_fK-_FQtUYR67fyWGZlN5SzgZuhjD4RGDA,5295
|
|
25
|
+
django_display_ids-0.3.1.dist-info/RECORD,,
|
|
File without changes
|