Scott Anderson wrote:
> You could also do this:
>
> ContentType.objects.filter(app_label__exact='aiyo',
> model__in=('content', 'product'))
>
> which is more concise and may treat the query optimizer in your database
> better.

hi Scott,

this is great! however, I'm having another problem, let me put it
straight:

I'm building a generic purpose bookmark app, which could be used to:

1. bookmark models in 'bookmarkable_list' of a django site
2. bookmark external urls

I built the 'bookmarkable_list' from settings.py in the following way:

== settings.py ==

BOOKMARKABLE_APP_MODEL_LIST = ['aiyo.content', 'aiyo.product',
'comments.comment', 'comments.freecomment']

== bookmark.py ==

from agv.settings import BOOKMARKABLE_APP_MODEL_LIST
q = Q()
for app_model in BOOKMARKABLE_APP_MODEL_LIST:
        app_label, model = app_model.split('.')
        q = q | (Q(app_label__exact=app_label) & Q(model__exact=model))

BOOKMARKABLE_DJANGO_CONTENT_TYPE_ID_LIST = [str(d['id']) for d in
ContentType.objects.filter(q).values('id')]

any advice to make it better?

Regards,

- Eric


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to