#20088 closed Bug (fixed)
Django admin log depends on User model having a field named id
| Reported by: | Owned by: | jcatalan | |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Normal | Keywords: | configurable, user, model |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | yes |
| Easy pickings: | no | UI/UX: | no |
Description
See https://github.com/django/django/blob/master/django/contrib/admin/templatetags/log.py#L20
Either we need to document that a User's pk must be named id and be integral or refactor the code linked above to not depend on it.
Change History (7)
comment:1 by , 13 years ago
| Patch needs improvement: | set |
|---|
comment:2 by , 13 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
I think that's the same problem as #20049.
comment:3 by , 13 years ago
No. #20049 is about the models themselves being incapable to be acted upon if they have non-integer primary keys (I actually don't encounter that bug using mysql and InnoDB).
This issue causes Login to fail as the get_admin_log template tag is attempting to retrieve users by a relation lookup. If you change the linked code to the snippet above it works (at least in my application).
comment:4 by , 13 years ago
| Resolution: | duplicate |
|---|---|
| Status: | closed → new |
Mmm, right, this could probably be fixed independently.
comment:5 by , 13 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:6 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Something like the following works in my application.
def render(self, context): entries = LogEntry.objects.all() if self.user is not None: entries = LogEntry.objects.filter(user__exact=self.user) context[self.varname] = entries.select_related('content_type', 'user')[:self.limit] return ''