On Thu, Oct 29, 2009 at 10:18 AM, pbzRPA wrote:
> It's a pity django does not provide this kind of
> functionality.
hum it would be a pretty impressive feat for an ORM to take some
arbitrary python code and recompile it to (portable!) SQL to make the
DB do the work.
--
Javier
--~--~--
Thank you for your help. I guess I will have to create temp table etc
and do it that way. It's a pity django does not provide this kind of
functionality.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users"
I think if your methods are really complex then the best you can do is
to denormalise your DB.
Make your calculated fields real fields in a table and update them in
model's save method or using signals.
Another way is to make them calculated by DB using triggers or DB
views but I would prefer den
I think my problem is both 1 and 2. What happens when you want to use
python modules to analyse the extra field?
For Example:
Database table History:
id | Ordered | Delivered | Invoiced |
1 10 15 5
2 553
c
Maybe I wrote a reply without undersanding what you need.
You have 2 separate issues:
1. Want to sort and filter by calculated field
2. Want to create calculated field that is calculated in python
Am I correct?
1) can be acheived using ".extra" method or aggregations
http://docs.djangoproject
Thanks for you reply Mikhail,
I do use model managers but more often to get a certain defined
queryset back. Could you maybe show me a simple example of how to
implement your suggestion?
I imagine it looking something like this.
class PersonManager(models.Manager):
def get_query_set(self):
If you want to be able to sort by some python method you have to fetch
ALL data from all tables that are used in this method. It is indeed a
bad practice and so it is not encouraged in django.
The best you can do is to put your code to model's manager as a
method. Model managers are often used fo
Sorry I would also like to add that I would like to sort by this field
in generic views. So results = Person.objects.filter
(compare_to_others__gte = 1).order_by('compare_to_others')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to th
Hi all,
I keep running into a problem. Often when creating models for existing
databases which you can not modify, I find myself in need of quite a
few model methods. That all works fine but then when I run a view I
would like to be able to use the object mapper to filter by the method
on a model
9 matches
Mail list logo