Opened 6 months ago

Closed 5 months ago

#35580 closed Bug (fixed)

System check fields.E300 does not allow for related fields involving auto_created through models.

Reported by: Jason Bruce Owned by: Jason Bruce
Component: Database layer (models, ORM) Version: 5.1
Severity: Normal Keywords:
Cc: Jason Bruce, Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The model system checks will raise the fields.E300 error if you make an auto_created through model the target of a related field. Here is an example of models that will trigger this error:

class E300TestModelA(models.Model):
    pass

class E300TestModelB(models.Model):
    many_to_many_rel = models.ManyToManyField(E300TestModelA)

class E300TestModelC(models.Model):
    one_to_one_rel = models.OneToOneField("check_framework.E300TestModelB_many_to_many_rel", on_delete=models.CASCADE)

I realize this might be an unusual thing to do, however I have a use case that requires this and thought I would create this ticket in case others agree that this should be changed. I will create a pull request shortly.

Change History (10)

comment:1 by Jason Bruce, 6 months ago

Owner: set to Jason Bruce
Status: newassigned

comment:2 by Jason Bruce, 6 months ago

Has patch: set

comment:3 by Jason Bruce, 6 months ago

Owner: Jason Bruce removed
Status: assignednew

comment:4 by Jason Bruce, 6 months ago

I created a pull request with a fix for the bug and a regression test.

comment:5 by Sarah Boyce, 5 months ago

Cc: Simon Charette added
Triage Stage: UnreviewedAccepted

Thank you for the report and patch

comment:6 by Sarah Boyce, 5 months ago

Owner: set to Jason Bruce
Patch needs improvement: set
Status: newassigned

comment:7 by Jason Bruce, 5 months ago

Owner: Jason Bruce removed
Patch needs improvement: unset
Status: assignednew

I updated my pr. Please let me know if there is anything else I can improve.

comment:8 by Jacob Walls, 5 months ago

Owner: set to Jason Bruce
Status: newassigned

comment:9 by Sarah Boyce, 5 months ago

Triage Stage: AcceptedReady for checkin

comment:10 by Sarah Boyce <42296566+sarahboyce@…>, 5 months ago

Resolution: fixed
Status: assignedclosed

In af84bcc8:

Fixed #35580 -- Allowed related fields referencing auto-created through models.

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