Skip to content

Commit

Permalink
Edit test models, uses ObjectId instead of positiveIntegerField.
Browse files Browse the repository at this point in the history
  • Loading branch information
WaVEV committed Sep 17, 2024
1 parent de48a57 commit 640aef4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion django/contrib/admin/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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
Expand Down Expand Up @@ -63,7 +64,7 @@ class LogEntry(models.Model):
blank=True,
null=True,
)
object_id = models.TextField(_("object id"), blank=True, null=True)
object_id = ObjectIdField(_("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)
Expand Down
13 changes: 7 additions & 6 deletions tests/generic_relations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
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):
"""A tag on an item."""

tag = models.SlugField()
content_type = models.ForeignKey(ContentType, models.CASCADE)
object_id = models.PositiveIntegerField()
object_id = ObjectIdField()

content_object = GenericForeignKey()

Expand All @@ -40,7 +41,7 @@ class AbstractComparison(models.Model):
content_type1 = models.ForeignKey(
ContentType, models.CASCADE, related_name="comparative1_set"
)
object_id1 = models.PositiveIntegerField()
object_id1 = ObjectIdField()

first_obj = GenericForeignKey(ct_field="content_type1", fk_field="object_id1")

Expand All @@ -54,7 +55,7 @@ class Comparison(AbstractComparison):
content_type2 = models.ForeignKey(
ContentType, models.CASCADE, related_name="comparative2_set"
)
object_id2 = models.PositiveIntegerField()
object_id2 = ObjectIdField()

other_obj = GenericForeignKey(ct_field="content_type2", fk_field="object_id2")

Expand Down Expand Up @@ -119,20 +120,20 @@ class ValuableRock(Mineral):


class ManualPK(models.Model):
id = models.IntegerField(primary_key=True)
id = ObjectIdField(primary_key=True)
tags = GenericRelation(TaggedItem, related_query_name="manualpk")


class ForProxyModelModel(models.Model):
content_type = models.ForeignKey(ContentType, models.CASCADE)
object_id = models.PositiveIntegerField()
object_id = ObjectIdField()
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 = models.PositiveIntegerField()
object_id = ObjectIdField()
obj = GenericForeignKey()


Expand Down

0 comments on commit 640aef4

Please sign in to comment.