#32847: Adjust models.E025 system check for updated field descriptor setting.
-------------------------------------+-------------------------------------
Reporter: Carlton Gibson | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):
I spent some time reading this ticket and following the referenced PRs and
associated tickets. I think I understand the overall history of the issue,
though I'm somehow lost when it comes to small/specific details. Having
said that, I did try to create a scenario to answer the question:
Can we still though detect that such a configuration error occurred,
i.e. that I named a property *_id matching an FK accessor
and while I don't yet have an answer about ''detect such configuration'',
it's definitely something that in some situations yield to a surprising
result. For example:
{{{
class ModelA(models.Model):
title = models.CharField(max_length=50)
class ModelB(models.Model):
modela = models.ForeignKey(ModelA, on_delete=models.CASCADE)
foo = models.CharField(max_length=3, default='foo')
@property
def modela_id(self):
return 'ERROR'
}}}
Produces models such as any instance of `ModelB` has `modela_id`
effectively being the id of the related `ModelA` instance, instead of
returning the string `ERROR`. As a user, I would appreciate if this
produces a check error or a migration failure or some sort of warning. The
same happens if one would add this field to `ModelB`:
{{{
modela_id = models.IntegerField(default=-100)
}}}
When running `makemigrations`, `No changes detected` is reported and
`modela_id` keeps returning the id of the related `ModelA` instance.
So I would not close this issue, I think at some point we'd want to be
able to produce some check/warning about this clashing.
--
Ticket URL: <https://code.djangoproject.com/ticket/32847#comment:4>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701877687d5cf-aa319f63-0aa3-41ac-8819-866e8fbcc41a-000000%40eu-central-1.amazonses.com.