#21730 closed Cleanup/optimization (fixed)
Small confusion code example in documentation
Reported by: | Rafał Pitoń | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The code example on following page:
sets both unique=True and db_index=True attributes on model field, yet documentation for unique attribute claims thats not necessary:
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.unique
"Note that when unique is True, you don’t need to specify db_index, because unique implies the creation of an index."
This gave me small scare, so I'm reporting it to bring it up to the doc maintainers attention. ;)
Change History (6)
follow-up: 6 comment:1 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:2 by , 11 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → new |
Well it's still necessary to remove the redundant db_index. AFAIK it creates a second index that wastes space without any benefit.
comment:3 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → Cleanup/optimization |
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 11 years ago
Replying to russellm:
I'm not sure I understand - what exactly about this is scary? It's just saying that adding db_index=True is redundant if you've also specified unique=True.
It gave me scare because it made me question if my model definitions are doing what I was thinking they are doing. Rest assured, its not a comment about quality of documentation or anything like that ;)
I'm not sure I understand - what exactly about this is scary? It's just saying that adding db_index=True is redundant if you've also specified unique=True.
Closing needsinfo; if you can suggest better language, or can provide a pointer about what exactly is "scary" about the current language, please reopen.