Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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:

https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD

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)

comment:1 by Russell Keith-Magee, 11 years ago

Resolution: needsinfo
Status: newclosed

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.

comment:2 by Aymeric Augustin, 11 years ago

Resolution: needsinfo
Status: closednew

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 Claude Paroz, 11 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:4 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In c717ebbfecd248d1a0ffeffa6d167109936fbe3f:

Fixed #21730 -- Removed superfluous db_index in custom auth docs

Thanks rafalp for the report.

comment:5 by Claude Paroz <claude@…>, 11 years ago

In 5d99cd6877377824a6a5de92475ad0572ab6fb0f:

[1.6.x] Fixed #21730 -- Removed superfluous db_index in custom auth docs

Thanks rafalp for the report.
Backport of c717ebbfec from master.

in reply to:  1 comment:6 by Rafał Pitoń, 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 ;)

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