Re: Compare the fields of the same model

2009-01-22 Thread Costin Stroie
I have implemented a very basic Q object. Under controlled conditions, it works great. Here it is: class QCompare(models.Q): """ QCompare object allows you to compare two fields of one or two models Example: queryset.filter(QCompare('>', Model1, 'field1', Model2, 'field2')) """

Re: Compare the fields of the same model

2009-01-21 Thread Costin Stroie
On Jan 21, 9:27 am, urukay wrote: > Hi > > i would use raw SQL to retrieve models, that would be the fastest way i > quess:http://docs.djangoproject.com/en/dev/topics/db/sql/ > > from django.db import connection > > cursor = connection.cursor() > cursor.execute(...Sqlquery...) > ... > ...

Re: Compare the fields of the same model

2009-01-20 Thread urukay
it? Maybe a forged Q object? Well, I'm stuck. > > > > -- View this message in context: http://www.nabble.com/Compare-the-fields-of-the-same-model-tp21547991p21578262.html Sent from the django-users mailing list archive at Nabble.com. --~--~-~--~~~--

Compare the fields of the same model

2009-01-19 Thread Costin Stroie
Hi! I have the following model: class MyModel(models.Model): maxwidth = models.IntegerField(Maximum width', default = '0') width = models.IntegerField('Width', default = '0') I need to perform a query similar to this: SELECT * FROM mymodel WHERE width > maxwidth; The result should be