#20049 closed Bug (needsinfo)
Admin incompatible with non-integer primary keys
Reported by: | Aymeric Augustin | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Since the admin log uses a GFK with an integer object_id
, creating, modifying or deleting an object with a non-integer primary key fails.
For instance, it's impossible to edit the following model in the admin:
from django.db import models class Release(models.Model): version = models.CharField(max_length=16, primary_key=True)
Change History (7)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 12 years ago
I just tested this on the development version and it seems to work fine.
comment:4 by , 12 years ago
Have you tested with a database that enforces types, ie. not SQLite?
On SQLite Django happily saves a string in an integer field and the bug doesn't appear.
comment:6 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
I don't doubt there are issues with non-integer PKs, but we still miss failure data. LogEntry.object_id
is a TextField
, so this is not the culprit. And I could add and delete an object with a non-integer primary key with Postgres.
As a workaround, one can disable logging by adding these lines to the
ModelAdmin
class: