Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
602a66d
disable JavaScript/Windows tests
timgraham Feb 11, 2025
948e0f8
use ObjectIdAutoField for contrib apps' default_auto_field
timgraham Apr 17, 2024
6d39ce0
Fixed #35402 -- Fixed (naively) django_test_skips crash when referenc…
timgraham Apr 25, 2024
4dd7ec9
Added DatabaseFeatures.supports_microsecond_precision.
timgraham May 29, 2024
07b0849
TruncQuarter, delta timezones, & tzinfo parameter not supported
timgraham Jun 1, 2024
3ea0cd1
Updated JSONField's test_invalid_value.
timgraham Jun 28, 2024
e2b06d0
Added regression tests for MongoDB $regexMatch pattern matching.
timgraham Jun 28, 2024
c7198ae
Update GenericForeignKey object_id to CharField/TextField
timgraham Jul 17, 2024
34e451a
use ObjectIdAutoField in test models
timgraham Jul 17, 2024
b9c9da8
comment out usage of QuerySet.extra()
timgraham Jul 18, 2024
7e5fe3a
remove unsupported usage of nulls_first
timgraham Jul 22, 2024
141c636
drop requirement that QuerySet.explain() log a query
timgraham Aug 16, 2024
17f1dfd
aggregation, aggregation_regress edits
timgraham Aug 19, 2024
9940a20
schema and migrations test edits
timgraham Aug 24, 2024
088579a
backends edits
timgraham Aug 29, 2024
3f63a6b
introspection test edits
timgraham Aug 27, 2024
633747b
remove SQL introspection from queries tests
timgraham Sep 3, 2024
afabcfd
Added QuerySet.union() test with renames.
WaVEV Sep 7, 2024
678c3ca
edits for many test apps
timgraham Sep 26, 2024
e129fe5
indexes
timgraham Oct 14, 2024
a571a2c
allow runtests.py to discover tests in django_mongodb/tests
timgraham Oct 22, 2024
5aa4390
constraints edits for partial indexes
timgraham Nov 7, 2024
377ad53
fix test_model_admin_default_delete_action
timgraham Dec 14, 2024
cc1a56b
adapt tests for ObjectIdAutoField
timgraham Feb 11, 2025
7ad6880
Fixed #36201 -- Fixed `ModelChoiceField/ModelMultipleChoiceField.clea…
timgraham Feb 20, 2025
fd544e8
Fixed shortcut() crash on ObjectId pk
timgraham Feb 20, 2025
4045820
mock close_pool() in test_creation.py
timgraham May 6, 2025
843107a
Removed hardcoded pks in admin selenium tests.
timgraham May 8, 2025
7b83596
Refs #34488 -- Fixed file path for ClearableFileInput selenium tests.
timgraham May 8, 2025
3803ba4
adaptions for transactions supports
timgraham Jun 7, 2025
57a8df9
use skipUnlessGISLookup
timgraham May 27, 2025
3d1d7c8
Add tests for MultiPointField, MultiLineStringField, and GeometryColl…
timgraham Jul 25, 2025
0f6a6e7
adapt GIS tests for MongoDB
timgraham May 24, 2025
d8f1da8
AutoField unsupported in Cast tests
timgraham Aug 6, 2025
0cc3c70
INTPYTHON-736 - Update test to not expect
NoahStapp Sep 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions .github/workflows/tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion django/contrib/admin/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class SimpleAdminConfig(AppConfig):
"""Simple AppConfig which does not do automatic discovery."""

default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
default_site = "django.contrib.admin.sites.AdminSite"
name = "django.contrib.admin"
verbose_name = _("Administration")
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/auth/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class AuthConfig(AppConfig):
default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
name = "django.contrib.auth"
verbose_name = _("Authentication and Authorization")

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/contenttypes/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class ContentTypesConfig(AppConfig):
default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
name = "django.contrib.contenttypes"
verbose_name = _("Content Types")

Expand Down
4 changes: 2 additions & 2 deletions django/contrib/contenttypes/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.http import Http404, HttpResponseRedirect
from django.utils.translation import gettext as _

Expand All @@ -19,7 +19,7 @@ def shortcut(request, content_type_id, object_id):
% {"ct_id": content_type_id}
)
obj = content_type.get_object_for_this_type(pk=object_id)
except (ObjectDoesNotExist, ValueError):
except (ObjectDoesNotExist, ValidationError, ValueError):
raise Http404(
_("Content type %(ct_id)s object %(obj_id)s doesn’t exist")
% {"ct_id": content_type_id, "obj_id": object_id}
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/flatpages/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@


class FlatPagesConfig(AppConfig):
default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
name = "django.contrib.flatpages"
verbose_name = _("Flat Pages")
2 changes: 1 addition & 1 deletion django/contrib/gis/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class GISConfig(AppConfig):
default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
name = "django.contrib.gis"
verbose_name = _("GIS")

Expand Down
12 changes: 0 additions & 12 deletions django/contrib/gis/db/backends/base/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ class BaseSpatialFeatures:
# for empty results?
empty_intersection_returns_none = True

@property
def supports_bbcontains_lookup(self):
return "bbcontains" in self.connection.ops.gis_operators

@property
def supports_contained_lookup(self):
return "contained" in self.connection.ops.gis_operators

@property
def supports_crosses_lookup(self):
return "crosses" in self.connection.ops.gis_operators
Expand All @@ -74,10 +66,6 @@ def supports_crosses_lookup(self):
def supports_distances_lookups(self):
return self.has_Distance_function

@property
def supports_dwithin_lookup(self):
return "dwithin" in self.connection.ops.gis_operators

@property
def supports_relate_lookup(self):
return "relate" in self.connection.ops.gis_operators
Expand Down
3 changes: 3 additions & 0 deletions django/contrib/gis/db/backends/base/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ def select_extent(self):
"AsGML",
"AsKML",
"AsSVG",
"AsWKB",
"AsWKT",
"Azimuth",
"BoundingCircle",
"Centroid",
"ClosestPoint",
"Difference",
"Distance",
"Envelope",
"ForcePolygonCW",
"FromWKB",
"FromWKT",
"GeoHash",
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/redirects/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@


class RedirectsConfig(AppConfig):
default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
name = "django.contrib.redirects"
verbose_name = _("Redirects")
2 changes: 1 addition & 1 deletion django/contrib/sites/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class SitesConfig(AppConfig):
default_auto_field = "django.db.models.AutoField"
default_auto_field = "django_mongodb_backend.fields.ObjectIdAutoField"
name = "django.contrib.sites"
verbose_name = _("Sites")

Expand Down
4 changes: 3 additions & 1 deletion django/contrib/sites/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django_mongodb_backend.fields import ObjectIdAutoField

import django.contrib.sites.models
from django.contrib.sites.models import _simple_domain_name_validator
from django.db import migrations, models
Expand All @@ -12,7 +14,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
models.AutoField(
ObjectIdAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
Expand Down
18 changes: 18 additions & 0 deletions django/core/management/commands/loaddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
DEFAULT_DB_ALIAS,
DatabaseError,
IntegrityError,
connection,
connections,
router,
transaction,
Expand Down Expand Up @@ -251,7 +252,24 @@ def load_label(self, fixture_label):

for obj in objects:
objects_in_fixture += 1

# Workaround for MongoDB to ignore unsupported SRIDs in test
# fixtures.
if connection.features.gis_enabled:
from django.contrib.gis.db.models import GeometryField

invalid_srid = False
for field in obj.object._meta.fields:
if isinstance(field, GeometryField):
val = getattr(obj.object, field.name)
if val and val.srid in {32140, 2278}:
invalid_srid = True
break
if invalid_srid:
continue

if self.save_obj(obj):

loaded_objects_in_fixture += 1
if show_progress:
self.stdout.write(
Expand Down
3 changes: 3 additions & 0 deletions django/db/backends/base/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ def mark_expected_failures_and_skips(self):
test_app = test_name.split(".")[0]
# Importing a test app that isn't installed raises RuntimeError.
if test_app in settings.INSTALLED_APPS:
# If this is a a test class, it may need to be imported.
if test_name.count(".") == 2:
import_string(test_name)
test_case = import_string(test_case_name)
test_method = getattr(test_case, test_method_name)
setattr(test_case, test_method_name, skip(reason)(test_method))
Expand Down
3 changes: 3 additions & 0 deletions django/db/backends/base/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class BaseDatabaseFeatures:
# by returning the type used to store duration field?
supports_temporal_subtraction = False

# Do time/datetime fields have microsecond precision?
supports_microsecond_precision = True

# Does the __regex lookup support backreferencing and grouping?
supports_regex_backreferencing = True

Expand Down
9 changes: 7 additions & 2 deletions django/forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,12 @@ def to_python(self, value):
if isinstance(value, self.queryset.model):
value = getattr(value, key)
value = self.queryset.get(**{key: value})
except (ValueError, TypeError, self.queryset.model.DoesNotExist):
except (
ValueError,
TypeError,
ValidationError,
self.queryset.model.DoesNotExist,
):
raise ValidationError(
self.error_messages["invalid_choice"],
code="invalid_choice",
Expand Down Expand Up @@ -1640,7 +1645,7 @@ def _check_values(self, value):
self.validate_no_null_characters(pk)
try:
self.queryset.filter(**{key: pk})
except (ValueError, TypeError):
except (ValueError, TypeError, ValidationError):
raise ValidationError(
self.error_messages["invalid_pk_value"],
code="invalid_pk_value",
Expand Down
4 changes: 3 additions & 1 deletion tests/admin_changelist/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import uuid

from django_mongodb_backend.fields import ObjectIdAutoField

from django.contrib.auth.models import User
from django.db import models

Expand Down Expand Up @@ -130,7 +132,7 @@ class OrderedObject(models.Model):


class CustomIdUser(models.Model):
uuid = models.AutoField(primary_key=True)
uuid = ObjectIdAutoField(primary_key=True)


class CharPK(models.Model):
Expand Down
Loading