Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24679 closed Bug (invalid)

Auth User last_login initialized as NULL from 1.8, old DB conflicts, documentation update

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

Description

In 1.8, there was a change to the User model where last_login is set to NULL when a new user is created.

Databases created under older versions have a NOT NULL constraint on the last_login column of auth_user. An app that tries to auto-create a user non-interactively via create_user() will fail due to the database conflict.

The 1.8 release notes do not refer (directly) to this change; the Authentication documentation mentions it in passing but doesn't warn of the consequences.

This should be made clear in the release notes and in the Authentication documentation. In my case, my test suite didn't pick it up because the test database is created from scratch.

Change History (3)

comment:1 by Baptiste Mispelon, 9 years ago

Resolution: invalid
Status: newclosed

Hi,

A migration was shipped alongside this change and you should make sure it's run, as documented in the release notes: https://docs.djangoproject.com/en/1.8/releases/1.8/#abstractuser-last-login-allows-null-values.

This should fix the database conflicts that you mention.

Thanks.

comment:2 by Mark Tranchant, 9 years ago

Thanks. Looks like a prior migration failed in my case due to a manually-caused discrepancy between dev and prod DBs, so I hadn't noticed this hadn't run.

However, I still think there's a communication issue. I've been using Django for six years, and hit this problem despite that experience. The release notes reference AbstractUser, which I didn't recognize as something I'm using (base class for User).

comment:3 by Tim Graham, 9 years ago

Feel free to propose a change with a pull request.

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