1 Jul 2007 08:31
Re: How to query in multiple tables?
Davide.D <dengyuanzhong <at> gmail.com>
2007-07-01 06:31:13 GMT
2007-07-01 06:31:13 GMT
>If you don't want to do that, just construct one queryset for each model
>and then join the results together in Python. You get to decide which
>trade-off you prefer: more queries and simpler code (appropriate if you
>have only a few models and/or not many results) or fewer queries and
>more complex Python code.
Queryset is not a list?
I can't use the extend() method. -->
from django.db.models.loading import get_app, get_models
...
model_list = get_models(get_app('myapp'))
resultset = []
for model in model_list:
resultset_tmp=model.objects.filter(part_number__icontains = q)
resultset.extend(resultset_tmp)
--~--~---------~--~----~------------~-------~--~----~
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 <at> googlegroups.com
To unsubscribe from this group, send email to django-users-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
RSS Feed