Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#198 closed enhancement (fixed)

istartswith doesn't work

Reported by: brantley (deadwisdom@… Owned by: adrian
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: UI/UX:

Description

istartswith is not working.

Attachments (0)

Change History (7)

comment:1 Changed 9 years ago by jacob

  • Resolution set to worksforme
  • Status changed from new to closed

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 9 years ago by adrian

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

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

  • Resolution worksforme deleted
  • Status changed from closed to reopened

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 Changed 9 years ago by brantley (deadwisdom@…

Oh, and I'm using revision 320.

comment:5 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from reopened to closed

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

comment:6 Changed 8 years ago by anonymous

  • Component changed from Database wrapper to Contrib apps
  • milestone set to Version 0.91
  • priority changed from normal to low
  • Severity changed from normal to critical
  • Type changed from defect to enhancement
  • Version set to magic-removal

comment:7 Changed 7 years ago by adrian

  • milestone Version 0.91 deleted

Milestone Version 0.91 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.