#28011: Correct Field.hidden docs regarding what fields are hidden
-----------------------------------------+------------------------
Reporter: Tim Graham | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The
[https://github.com/django/django/blob/d4d79d0f200357b28419203557cc61c8168316ab/docs/ref/models/fields.txt#L1912-L1918
Field.hidden] docs say, "Boolean flag that indicates if a field is used to
back another non-hidden field’s functionality (e.g. the content_type and
object_id fields that make up a GenericForeignKey)." This seems
inaccurate:
{{{#!python
from django.contrib.contenttypes.fields import GenericForeignKey,
GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.db import models
class TaggedItem(models.Model):
tag = models.SlugField()
content_type = models.ForeignKey(ContentType,
on_delete=models.CASCADE, related_name='tagged_items')
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
>>> TaggedItem._meta.get_field('object_id')
<django.db.models.fields.PositiveIntegerField: object_id>
>>> TaggedItem._meta.get_field('content_type')
<django.db.models.fields.related.ForeignKey: content_type>
}}}
(`object_id` and `content_type` aren't hidden).
There's a related discussion in the
[https://github.com/django/django/blob/d4d79d0f200357b28419203557cc61c8168316ab/docs/ref/models/meta.txt#L79-L84
Options.get_fields() docs] that also needs some correction.
Another thing I noticed is that `Field.hidden` is
[https://github.com/django/django/blob/d4d79d0f200357b28419203557cc61c8168316ab/django/db/models/options.py#L792-L793
only consulted for relational fields]. Removing `Field.hidden` and
`GenericForeignKey.hidden` doesn't result in any crash of `get_fields()`
because those attributes are never consulted.
--
Ticket URL: <https://code.djangoproject.com/ticket/28011>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.26701ec88fda882a419f8885bc86560f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.