#32868: Add system check or warning for model fields shadowing methods / other
attributes
------------------------------------------------+------------------------
Reporter: Adam Johnson | Owner: nobody
Type: New feature | Status: new
Component: Core (System checks) | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
It's possible to create a field name that replaces a Model method, for
example:
{{{
from django.db import models
class Book(models.Model):
delete = models.BooleanField(default=False)
}}}
Instances of this model then cannot be deleted with `instance.delete()`.
(They can be with `Model.delete(instance)`, but that's a really rare way
of using a method so I expect most developers would not think of that.)
Django could warn about this, at least for some key names that sound like
feasible field names, e.g. `delete`, `save`, `pk`, `clean`, ...
It's already not possible to create a field called `check` since the
system check `models.E020` warns if the `Model.check()` method has been
replaced, added in #23615. We could see this ticket as an extension of
that, "reserving" more names that Django may depend on.
--
Ticket URL: <https://code.djangoproject.com/ticket/32868>
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/053.749f7ca7a72ae7f529785f4e5ca8ac4f%40djangoproject.com.