Opened 13 years ago
Closed 13 years ago
#18093 closed New feature (fixed)
AnonymousUser should have a 'pk' attribute
Reported by: | Chris Lamb | Owned by: | |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
I like the "pk" field on models as it means I can refer to the primary key of any instance without having to know some implementation detail about the model.
However, this idea breaks down with the AnonymousUser pseudo-model; it has an id element (of None) but it has no pk element. This requires some special-casing which I would like to be rid of.
Sure, it's not a real model. But if AnonymousUser has an 'id' element and can exist where a "real" auth.User may exist, it might as well have an 'pk' too.
Patch is trivial.
Attachments (1)
Change History (9)
comment:1 by , 13 years ago
Has patch: | unset |
---|
comment:2 by , 13 years ago
Component: | Uncategorized → contrib.auth |
---|---|
Summary: | AnonymousUser should have a 'pk' element → AnonymousUser should have a 'pk' attribute |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → New feature |
While from a purity point of view - "primary key" pk implies a database persistence, the truth is that in Django models, pk is more removed from the actual db column than id is.
However I can't imagine any major negative impacts from also setting pk=None in AnonymousUser
comment:3 by , 13 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 13 years ago
Needs tests: | set |
---|
comment:5 by , 13 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
Version: | 1.4 → SVN |
comment:6 by , 13 years ago
Needs tests: | unset |
---|
I've added another patch with a test included. If the test is in the wrong place please let me know how I can add it in the right location. Thanks.
comment:8 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed #18093 -- Added a pk to AnonymousUser.
Changeset: b1155adcde0282a533a5ad1d7220adbd52011230
If the patch is trivial, please add it to this ticket. I remove "has patch".