Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#198 closed enhancement (fixed)

istartswith doesn't work

Reported by: brantley (deadwisdom@… Owned by: Adrian Holovaty
Component: Contrib apps Version: magic-removal
Severity: critical Keywords: database lookup
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


istartswith is not working.

Change History (7)

comment:1 Changed 14 years ago by Jacob

Resolution: worksforme
Status: newclosed

Brantley: it works for me, so please try again and if you're still having problems reopen this ticket with more information about exactly what's not working.

comment:2 Changed 14 years ago by Adrian Holovaty

Also, let us know which database you're using.

comment:3 Changed 14 years ago by brantley (deadwisdom@…

Resolution: worksforme
Status: closedreopened

Maybe I'm using it incorrectly? I'm using mysql, and mod_python.

Here's my code:

def card_detail(request, name=None):
		card = cards.get_object(name__istartswith=name)
	except cards.CardDoesNotExist:
		return Render(request, 'message', {'message': 'Cannot find a card with the name, %r' % name})
	return Render(request, 'card', {'card': card})

Here's my output:

There's been an error:

Traceback (most recent call last):

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

  File "/home/deadwisdom/sites/magic/views/", line 18, in card_detail
    card = cards.get_object(name__istartswith=name)

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

  File "/usr/lib/python2.4/site-packages/django/core/", line 1032, in function_get_object
    obj_list = function_get_list(opts, klass, **kwargs)

  File "/usr/lib/python2.4/site-packages/django/core/", line 1054, in function_get_list
    select, sql, params = function_get_sql_clause(opts, **kwargs)

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

  File "/usr/lib/python2.4/site-packages/django/core/", line 1214, in _parse_lookup
    params.extend(f.get_db_prep_lookup(lookup_type, kwarg_value))

  File "/usr/lib/python2.4/site-packages/django/core/", line 1649, in get_db_prep_lookup
    raise TypeError, "Field has invalid lookup: %s" % lookup_type

TypeError: Field has invalid lookup: istartswith

comment:4 Changed 14 years ago by brantley (deadwisdom@…

Oh, and I'm using revision 320.

comment:5 Changed 14 years ago by Adrian Holovaty

Resolution: fixed
Status: reopenedclosed

(In [321]) Fixed #198 -- istartswith and iendswith weren't working properly. Thanks, brantley

comment:6 Changed 13 years ago by anonymous

Component: Database wrapperContrib apps
milestone: Version 0.91
priority: normallow
Severity: normalcritical
Type: defectenhancement
Version: magic-removal

comment:7 Changed 12 years ago by Adrian Holovaty

milestone: Version 0.91

Milestone Version 0.91 deleted

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