Opened 3 years ago

Closed 2 years ago

#19345 closed Bug (wontfix)

ContentType.objects.get_for_model shouldn't create missing content types

Reported by: aaugustin Owned by: nobody
Component: contrib.contenttypes Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This behavior is very unexpected, given the name of the method.

In general, this isn't an issue because content types always exist — they're created in post_syncdb.

I encountered the problem while debugging multiple databases issues involving syncdb (#16039). The post_syncdb handler that creates permissions looks for content types, creating them as a side effect. Since I was attempting to test that the content types weren't created, my test failed in a very unexpected fashion.

Change History (3)

comment:1 Changed 3 years ago by ptone

Seems that this behavior is fully intentional and long standing based on code comments and git-blame.

Given that as you say - this is mostly a non-issue either way under normal usage, and there is a slim chance that the backwards incompatible change to raise an error could cause some edge case breakage - wouldn't it be better to leave as is and just access the ContentType model through standard manager methods?

Basically - is this worth changing?

comment:2 Changed 3 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 2 years ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

I can't come up with a sufficiently good reason to justify changing this, and I suppose I can live with it, if I never attempt to debug syncdb again ;)

Note: See TracTickets for help on using tickets.
Back to Top