Skip to content

Commit

Permalink
add admin_views w/ObjectIdAutoField.to_python() fix for string integers
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Oct 24, 2024
1 parent 0d45d29 commit 34e799a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-python1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
admin_ordering
admin_scripts
admin_utils
admin_views
admin_widgets
apps
async
Expand Down
10 changes: 10 additions & 0 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ def django_test_expected_failures(self):
"update.tests.AdvancedTests.test_update_ordered_by_m2m_annotation_desc",
},
"QuerySet.dates() is not supported on MongoDB.": {
"admin_views.tests.AdminViewBasicTest.test_change_list_sorting_override_model_admin",
"admin_views.tests.AdminViewBasicTest.test_multiple_sort_same_field",
"admin_views.tests.AdminViewListEditable.test_inheritance",
"admin_views.tests.CSSTest.test_changelist_field_classes",
"admin_views.tests.DateHierarchyTests",
"aggregation.tests.AggregateTestCase.test_dates_with_aggregation",
"annotations.tests.AliasTests.test_dates_alias",
"aggregation_regress.tests.AggregationTests.test_more_more_more2",
Expand Down Expand Up @@ -294,6 +299,11 @@ def django_test_expected_failures(self):
"queryset_pickle.tests.PickleabilityTestCase.test_specialized_queryset",
},
"QuerySet.datetimes() is not supported on MongoDB.": {
"admin_views.test_templatetags.DateHierarchyTests",
"admin_views.test_templatetags.AdminTemplateTagsTest.test_override_change_list_template_tags",
"admin_views.tests.AdminViewBasicTest.test_date_hierarchy_empty_queryset",
"admin_views.tests.AdminViewBasicTest.test_date_hierarchy_local_date_differ_from_utc",
"admin_views.tests.AdminViewBasicTest.test_date_hierarchy_timezone_dst",
"annotations.tests.AliasTests.test_datetimes_alias",
"datetimes.tests.DateTimesTests.test_21432",
"datetimes.tests.DateTimesTests.test_datetimes_has_lazy_iterator",
Expand Down
13 changes: 8 additions & 5 deletions django_mongodb/fields/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ def to_python(self, value):
try:
return ObjectId(value)
except errors.InvalidId:
raise exceptions.ValidationError(
self.error_messages["invalid"],
code="invalid",
params={"value": value},
) from None
try:
return int(value)
except ValueError:
raise exceptions.ValidationError(
self.error_messages["invalid"],
code="invalid",
params={"value": value},
) from None

@cached_property
def validators(self):
Expand Down

0 comments on commit 34e799a

Please sign in to comment.