#33952: Too aggressive pk control in create_reverse_many_to_one_manager -------------------------------------+------------------------------------- Reporter: Claude | Owner: nobody Paroz | Type: Bug | Status: new Component: Database | Version: 4.1 layer (models, ORM) | Severity: Normal | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- In the context of #19580, Django now requires an instance pk to even instanciate a related manager [7ba6ebe9149a].
Now I have a use case where I need to introspect the model used by a related manager (`MyModel().related_set.model`) and Django 4.1 refuses that with `ValueError: 'MyModel' instance needs to have a primary key value before this relationship can be used.` My opinion is that is is too aggressive of a check and would suggest to let the `__init__` succeed even if the instance has no pk. Other calls to `_check_fk_val` in the class seems sufficient to me to safeguard against shooting in the foot. -- Ticket URL: <https://code.djangoproject.com/ticket/33952> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070182cbc105cc-b6eda030-5c6f-41eb-ad29-b93a1dfc27fc-000000%40eu-central-1.amazonses.com.