Opened 19 years ago

Closed 19 years ago

Last modified 17 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

Description

istartswith is not working.

Change History (7)

comment:1 by Jacob, 19 years ago

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 by Adrian Holovaty, 19 years ago

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

comment:3 by brantley (deadwisdom@…, 19 years ago

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):
	try:
		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/base.py", line 63, in get_response
    return callback(request, **param_dict)

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

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

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

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

  File "/usr/lib/python2.4/site-packages/django/core/meta.py", 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/meta.py", 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/meta.py", line 1649, in get_db_prep_lookup
    raise TypeError, "Field has invalid lookup: %s" % lookup_type

TypeError: Field has invalid lookup: istartswith

comment:4 by brantley (deadwisdom@…, 19 years ago

Oh, and I'm using revision 320.

comment:5 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: reopenedclosed

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

comment:6 by anonymous, 18 years ago

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

comment:7 by Adrian Holovaty, 17 years ago

milestone: Version 0.91

Milestone Version 0.91 deleted

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