Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24429 closed Cleanup/optimization (fixed)

Revise docs regarding non-int primary key on custom user models

Reported by: shadfc Owned by: nobody
Component: Documentation Version: 1.8beta1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The docs (https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#specifying-a-custom-user-model, point #1) say that a custom user model must have an integer primary key but do not specify why. https://code.djangoproject.com/ticket/24161 dealt with a session issue and has been fixed.

I would like to be able to use a UUID as the pk for a custom user model but this message makes me unsure if I should attempt that. Tim Graham suggested opening a ticket to investigate this issue and either remove that note from the docs or add a better explanation to it.

Change History (7)

comment:1 by shadfc, 9 years ago

Component: UncategorizedDocumentation

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:3 by Claude Paroz, 9 years ago

Has patch: set

The fact that we have tests for an UUIDUser (see #24161) should prove that the integer PK is no longer a requirement.

I'd suggest:

  • docs/topics/auth/customizing.txt

    diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt
    index 3833328..9c41e78 100644
    a b Specifying a custom User model  
    469469
    470470Django expects your custom User model to meet some minimum requirements.
    471471
    472 1. Your model must have an integer primary key.
    473 
    474 2. Your model must have a single unique field that can be used for
     4721. Your model must have a single unique field that can be used for
    475473   identification purposes. This can be a username, an email address,
    476474   or any other unique attribute.
    477475
    478 3. Your model must provide a way to address the user in a "short" and
     4762. Your model must provide a way to address the user in a "short" and
    479477   "long" form. The most common interpretation of this would be to use
    480478   the user's given name as the "short" identifier, and the user's full
    481479   name as the "long" identifier. However, there are no constraints on

comment:4 by Tim Graham, 9 years ago

I thought we might want to do a bit more thorough test/investigating instead of relying only on reports of things that *didn't* work.

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 981e3b9:

Fixed #24429 -- Doc'ed that Django 1.8 doesn't require an integer PK for custom user models.

comment:6 by Tim Graham <timograham@…>, 9 years ago

In 993074d:

[1.8.x] Fixed #24429 -- Doc'ed that Django 1.8 doesn't require an integer PK for custom user models.

Backport of 981e3b9394022810bd536474344e2f91c190b858 from master

comment:7 by Tim Graham, 9 years ago

For posterity, I didn't do any further investigation. Let's see if we get any reports about things that don't work.

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