A small code snippet to illustrate:
{{{
class Document(BaseModel):
related_id = models.UUIDField(
null=True,
blank=True,
db_index=True,
help_text=("The UUID of the origin model, which this flag came
from."),
)
related_type = models.ForeignKey(
ContentType,
null=True,
blank=True,
on_delete=models.SET_NULL,
help_text="Type that the Subject id relates to",
)
related = GenericForeignKey("related_type", "related_id")
doc1 = Document(data=b'',
related=company)
doc2 = Document(data=b'',
related_type=ContentType.objects.get_for_model(company),
related_id=company.id)
print(ContentType.objects.get_for_model(company).id)
>>> 23
print(doc1.related_type.id)
>>> 148
print(doc2.related_type.id)
>>> 23
}}}
For reference: There's no object with id 148 in the ContentTypes table so
I'm not sure where it's getting it from.
--
Ticket URL: <https://code.djangoproject.com/ticket/33614>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
I unfortunately cannot reproduce your reported issue on the latest version
of Django with your provided instructions (Defining a `Company` model of
my own with no fields).
Please re-open with a set of instructions that reproduces against a
supported version of Django (e.g. a sample project with a command or test
case that demonstrates an assertion failure).
--
Ticket URL: <https://code.djangoproject.com/ticket/33614#comment:1>