Opened 3 days ago

Last modified 57 minutes ago

#35580 new Bug

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

Reported by: Jason Bruce Owned by:
Component: Database layer (models, ORM) Version: 5.1
Severity: Normal Keywords:
Cc: Jason Bruce, Simon Charette Triage Stage: Accepted
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 (7)

comment:1 by Jason Bruce, 3 days ago

Owner: set to Jason Bruce
Status: newassigned

comment:2 by Jason Bruce, 3 days ago

Has patch: set

comment:3 by Jason Bruce, 3 days ago

Owner: Jason Bruce removed
Status: assignednew

comment:4 by Jason Bruce, 3 days ago

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

comment:5 by Sarah Boyce, 7 hours ago

Cc: Simon Charette added
Triage Stage: UnreviewedAccepted

Thank you for the report and patch

comment:6 by Sarah Boyce, 7 hours ago

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

comment:7 by Jason Bruce, 57 minutes 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.

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