caustic wrote:
>
> On May 17, 9:13 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
>   
>> Hi All,
>>
>> I am back with another query
>>
>> I have this (generic) view function
>>
>> --------------------------8><------------------------------------
>> def object_list(request, object, filter_string = None):
>>     if filter_string:
>>         object_list = object.objects.filter(filter_string)
>>     else:
>>         object_list = object.objects.all()
>>
>>     return render_to_response(object.__name__ + '_list.html',
>>                               {object.__name__ + '_list': object_list},
>>                               RequestContext(request))
>> --------------------------8><------------------------------------
>>
>> Now this function works when I don't pass on the filter_string, and I
>> get the entire object list. But when I pass on a value for filter_string
>> (say 'entity=2') I get this error :
>>
>> 'unicode' object has no attribute 'get_sql'
>>
>> How do I pass strings to filter_string and get a filtered object list?
>>     
> You cannot. You should pass either an instance of django.db.models.Q
> or a set of keyword arguments.
> This means you should change code in the object_list caller to do
> something like this:
>
> object_list(request, model.Object, Q(entity=2))
>   
Hmm. I'll have to read about Q objects...

Thanks for the pointer

Regards Ganesh


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to