Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #35545, Refs #32833 -- Fixed ContentTypeManager.get_for_models() crash in CreateModel migrations. #18294

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

sarahboyce
Copy link
Contributor

@sarahboyce sarahboyce commented Jun 21, 2024

Trac ticket number

ticket-35545

Branch description

Provide a concise overview of the issue or rationale behind the proposed changes.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

@sarahboyce
Copy link
Contributor Author

@csirmazbendeguz does this work for you?

Copy link
Member

@charettes charettes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is the right approach as it will allow models that are not registered in the registry associated with the ContentType model to have content types created for them.

Maybe that's a sign of a larger issue in the original patch?

tests/contenttypes_tests/test_models.py Show resolved Hide resolved
opts_models = needed_opts.pop(
ct._meta.apps.get_model(ct.app_label, ct.model)._meta, []
)
opts_models = needed_opts.pop((ct.app_label, ct.model), [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the crux of the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is the crux of it 👍

@sarahboyce
Copy link
Contributor Author

sarahboyce commented Jun 21, 2024

Maybe that's a sign of a larger issue in the original patch?

Which patch are you referring to here? 🙂

@csirmazbendeguz
Copy link
Contributor

@sarahboyce , your branch is working for me

@charettes
Copy link
Member

Which patch are you referring to here? 🙂

The one that introduced the regression #18105

Copy link
Member

@charettes charettes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is the right approach as it will allow models that are not registered in the registry associated with the ContentType model to have content types created for them.

It appears that get_for_model already has this peculiarity which explains why the code was working before #18105 was merged and switched to get_for_models.

Since it makes get_for_models more coherent with the canonical get_for_model I think this is fine.

…) crash in CreateModel migrations.

Thank you to Csirmaz Bendegúz for the report and Simon Charettes for the review.
@sarahboyce sarahboyce merged commit f1705c8 into django:main Jun 24, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants