Opened 17 years ago
Closed 17 years ago
#7099 closed (fixed)
FieldError in newforms admin when Meta.ordering contains a FK
Reported by: | Ramiro Morales | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | Keywords: | changelist newforms-admin FieldEerror fk ordering | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This is the newforms-admin equivalent of #3002. See http://code.djangoproject.com/ticket/3002#comment:3
Find attached patch fixing this (identical modulo lines offsets to the one attached to #3002).
This bug can be reproduced by this minimal app:
# models.py import datetime from django.db import models from django.contrib import admin from admin import PollAdmin, ChoiceAdmin class Poll(models.Model): question = models.CharField(max_length=200) def __unicode__(self): return self.question class Choice(models.Model): poll = models.ForeignKey(Poll, null=True) choice = models.CharField(max_length=200) def __unicode__(self): return self.choice class Meta: ordering = ('poll',) admin.site.register(Poll, PollAdmin) admin.site.register(Choice, ChoiceAdmin)
# admin.py from django.contrib import admin class PollAdmin(admin.ModelAdmin): pass class ChoiceAdmin(admin.ModelAdmin): pass
Problem shows itself when the "Choices" link is clicked in the admin index page. This is the traceback generated:
Environment: Request Method: GET Request URL: http://ikki:8000/admin/issues/choice/ Django Version: 0.97-newforms-admin-SVN-unknown Python Version: 2.4.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'nfa_test.issues'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Traceback: File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/core/handlers/base.py" in get_response 82. response = callback(request, *callback_args, **callback_kwargs) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/contrib/admin/sites.py" in root 137. return self.model_page(request, *url.split('/', 2)) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/contrib/admin/sites.py" in model_page 154. return admin_obj(request, rest_of_url) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/contrib/admin/options.py" in __call__ 242. return self.changelist_view(request) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/contrib/admin/options.py" in changelist_view 586. self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/contrib/admin/views/main.py" in __init__ 148. self.query_set = self.get_query_set() File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/contrib/admin/views/main.py" in get_query_set 309. qs = qs.order_by(order_type + lookup_order_field) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/db/models/query.py" in order_by 427. obj.query.add_ordering(*field_names) File "/mnt/disk2/ramiro/hg-repos/django/t3002-nf-a/django/db/models/sql/query.py" in add_ordering 1293. raise FieldError('Invalid order_by arguments: %s' % errors) Exception Type: FieldError at /admin/issues/choice/ Exception Value: Invalid order_by arguments: ['issues_poll.id']
Attachments (1)
Change History (4)
by , 17 years ago
Attachment: | t7099-nf-a-r7484.diff added |
---|
comment:1 by , 17 years ago
Has patch: | set |
---|
comment:2 by , 17 years ago
Summary: | FieldError in newforms admin when Meta.ordering contains by a FK → FieldError in newforms admin when Meta.ordering contains a FK |
---|
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed in newforms-admin by the merge from trunk of [7492].
Note:
See TracTickets
for help on using tickets.
Patch fixing the bug, for nf-a as of r7484