example code
qdict = QueryDict('id=1&fk_client_id=2')
queryset = Ticket.objects
for k, v in qdict.iteritems():
queryset = queryset.filter(k = v)
Essentially what I want to do here, is get a list of filter keywords
from an HTTP request, and then iterate through these to create the
final filtered results. I know there should be a better way to do this,
but my weak knowledge of python and django at the moment, prevent me
from coming up with one. Please see errors below.
This throws allot of errors.
Traceback (most recent call last):
File "<console>", line 1, in ?
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 97, in __repr__
return repr(self._get_data())
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 430, in _get_data
self._result_cache = list(self.iterator())
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 171, in iterator
select, sql, params = self._get_sql_clause()
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 444, in _get_sql_clause
joins2, where2, params2 = self._filters.get_sql(opts)
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 574, in get_sql
joins2, where2, params2 = val.get_sql(opts)
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 622, in get_sql
return parse_lookup(self.kwargs.items(), opts)
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 734, in parse_lookup
joins2, where2, params2 = lookup_inner(path, lookup_type, value,
opts, opts.
db_table, None)
File
"C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 835, in lookup_inner
raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError: Cannot resolve keyword 'k' into field
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---