diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 7e21f5971d..021984160a 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -9,7 +9,6 @@ from django.utils.text import get_text_list from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ -from django_mongodb.fields import ObjectIdField ADDITION = 1 CHANGE = 2 @@ -64,7 +63,7 @@ class LogEntry(models.Model): blank=True, null=True, ) - object_id = ObjectIdField(_("object id"), blank=True, null=True) + object_id = models.TextField(_("object id"), blank=True, null=True) # Translators: 'repr' means representation # (https://docs.python.org/library/functions.html#repr) object_repr = models.CharField(_("object repr"), max_length=200) diff --git a/tests/generic_relations/models.py b/tests/generic_relations/models.py index 8a1d36e790..a6021b8f16 100644 --- a/tests/generic_relations/models.py +++ b/tests/generic_relations/models.py @@ -12,7 +12,6 @@ from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models -from django_mongodb.fields import ObjectIdField class TaggedItem(models.Model): @@ -20,7 +19,7 @@ class TaggedItem(models.Model): tag = models.SlugField() content_type = models.ForeignKey(ContentType, models.CASCADE) - object_id = ObjectIdField() + object_id = models.TextField() content_object = GenericForeignKey() @@ -41,7 +40,7 @@ class AbstractComparison(models.Model): content_type1 = models.ForeignKey( ContentType, models.CASCADE, related_name="comparative1_set" ) - object_id1 = ObjectIdField() + object_id1 = models.TextField() first_obj = GenericForeignKey(ct_field="content_type1", fk_field="object_id1") @@ -55,7 +54,7 @@ class Comparison(AbstractComparison): content_type2 = models.ForeignKey( ContentType, models.CASCADE, related_name="comparative2_set" ) - object_id2 = ObjectIdField() + object_id2 = models.TextField() other_obj = GenericForeignKey(ct_field="content_type2", fk_field="object_id2") @@ -120,20 +119,20 @@ class ValuableRock(Mineral): class ManualPK(models.Model): - id = ObjectIdField(primary_key=True) + id = models.TextField(primary_key=True) tags = GenericRelation(TaggedItem, related_query_name="manualpk") class ForProxyModelModel(models.Model): content_type = models.ForeignKey(ContentType, models.CASCADE) - object_id = ObjectIdField() + object_id = models.TextField() obj = GenericForeignKey(for_concrete_model=False) title = models.CharField(max_length=255, null=True) class ForConcreteModelModel(models.Model): content_type = models.ForeignKey(ContentType, models.CASCADE) - object_id = ObjectIdField() + object_id = models.TextField() obj = GenericForeignKey() diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py index e0c6fe2db7..46da6a39a1 100644 --- a/tests/generic_relations/tests.py +++ b/tests/generic_relations/tests.py @@ -1,3 +1,4 @@ +from bson import ObjectId from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.prefetch import GenericPrefetch from django.core.exceptions import FieldError @@ -44,7 +45,7 @@ def setUpTestData(cls): def comp_func(self, obj): # Original list of tags: - return obj.tag, obj.content_type.model_class(), obj.object_id + return obj.tag, obj.content_type.model_class(), ObjectId(obj.object_id) async def test_generic_async_acreate(self): await self.bacon.tags.acreate(tag="orange")