Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#303 closed defect (invalid)

Error: got unexpected keyword argument when deleting object in admin interface

Reported by: Boffbowsh Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords: delete object admin
Cc: paul.bowsher@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Traceback:

There's been an error:

Traceback (most recent call last):

  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py", line 62, in get_response
    return callback(request, **param_dict)

  File "/usr/local/lib/python2.4/site-packages/django/views/admin/main.py", line 1061, in delete_stage
    _get_deleted_objects(deleted_objects, perms_needed, request.user, obj, opts, 1)

  File "/usr/local/lib/python2.4/site-packages/django/views/admin/main.py", line 1006, in _get_deleted_objects
    for sub_obj in getattr(obj, 'get_%s_list' % rel_opts_name)():

  File "/usr/local/lib/python2.4/site-packages/django/utils/functional.py", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))

  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 876, in method_get_related
    return getattr(rel_mod, method_name)(**kwargs)

  File "/usr/local/lib/python2.4/site-packages/django/utils/functional.py", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))

  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1066, in function_get_list
    return list(function_get_iterator(opts, klass, **kwargs))

  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1048, in function_get_iterator
    select, sql, params = function_get_sql_clause(opts, **kwargs)

  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1235, in function_get_sql_clause
    tables2, join_where2, where2, params2, _ = _parse_lookup(kwargs.items(), opts)

  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1171, in _parse_lookup
    _throw_bad_kwarg_error(kwarg)

  File "/usr/local/lib/python2.4/site-packages/django/core/meta/__init__.py", line 1124, in _throw_bad_kwarg_error
    raise TypeError, "got unexpected keyword argument '%s'" % kwarg

TypeError: got unexpected keyword argument 'team2__exact'

Model:

class Team (meta.Model):
	fields = (
		meta.CharField('teamname', maxlength=32),
		meta.CharField('tags', maxlength=8),
		meta.CharField('contact', maxlength=32, blank=True),
		meta.CharField('phone', maxlength=16, blank=True),
		meta.CharField('seatno', maxlength=6, blank=True),
	)

	def __repr__(self):
		return self.teamname
	
	admin = meta.Admin()

class Player (meta.Model):
	fields = (
		meta.CharField('realname', maxlength=32, blank=True),
		meta.IntegerField('bookingid'),
		meta.IntegerField('profileid', db_index=True),
		meta.CharField('ingamename', maxlength=32, db_index=True),
		meta.ForeignKey(Team, blank=True),
		meta.ForeignKey(Server, name="lastseenon")
	)

	def __repr__(self):
		return self.ingamename
	
	admin = meta.Admin(
			search_fields = ['ingamename', 'profileid'],
		)

class Team (meta.Model):
	fields = (
		meta.CharField('teamname', maxlength=32),
		meta.CharField('tags', maxlength=8),
		meta.CharField('contact', maxlength=32, blank=True),
		meta.CharField('phone', maxlength=16, blank=True),
		meta.CharField('seatno', maxlength=6, blank=True),
	)

	def __repr__(self):
		return self.teamname
	
	admin = meta.Admin()

When I delete a team, I get the traceback above and the team is not deleted

Change History (5)

comment:1 by Boffbowsh, 19 years ago

Just noticed i've not given anywhere near enough info for this, i pasted the model for Player instead of Match. I've now lost the model for Match, but it had two ForeignKeyFields,
ForeignKeyField(Team, rel_name="team1")
ForeignKeyField(Team, rel_name="team2")

comment:2 by Adrian Holovaty, 19 years ago

Is this problem still happening?

comment:3 by Boffbowsh, 19 years ago

Not used this app for a while, it was a temporary thing. I'll try and verify it tonight (8 hours ish)

comment:4 by Link, 18 years ago

Type: defect

comment:5 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed
Type: defect

With all the changes to related models and querying structure in the magic-removal branch and post-merge, it is unlikely this problem still occurs in its exact form. Closing now and please reopen with details if it reoccurs.

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