Hello everyone,

We've got a few models whose relationships are quite "involved" and I 
couldn't figure out how to simplify it further.

We need to query them using a GROUP BY query, which Django's ORM only 
provides limited support.

So I've built a postgres view and a managed=False model in Django so we can 
continue to use the ORM to further specify the query when needed.

i.e. https://gist.github.com/meric/d3a92402982c0dd3bb23

What do you think of this technique? Is it a good practice, have you tried 
it before, or do you foresee I'll experience performance challenges later 
on?

I'm worried about this because this view-model is going to be heavily 
relied upon and its query in CPU time would be more than any others.

I know this because we're refactoring our website and I hope I can remove 
all the series of ORM queries in our code that are merged together and 
paginated by python (rather than in the database itself as is typical 
practice), which is slow and the code hard to read, with this one model 
based on postgres view.

Best Regards,
Eric

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e4f9e4f-3a7a-447a-bf29-7547d049ae04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to