Re: order_by with foreign keys
On 9/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > that helps, thanks very much... > > i got a bit confused by all the tickets concerning this issue. also > the documentation doesn't mention any bugs, well bad luck ;) fortunately you can add a comment to the documentation, mentioning the bug, and pointing to the ticket with the patch that fixes the bug, right? :-D -- John Lenton ([EMAIL PROTECTED]) -- Random fortune: The trouble with a lot of self-made men is that they worship their creator. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: order_by with foreign keys
that helps, thanks very much... i got a bit confused by all the tickets concerning this issue. also the documentation doesn't mention any bugs, well bad luck ;) On 10 Sep., 17:53, Michael Radziej <[EMAIL PROTECTED]> wrote: > On Mon, Sep 10, [EMAIL PROTECTED] wrote: > > > hi guys, > > i noticed there have been questions about this before, but none of > > those threads was helpful. > > > i've got a simple db-request, the result should be ordered by a column > > "thema" in a foreign key table "Thema": > > Test.objects.select_related().order_by("my_app_thema.thema"): > > That's a known bug with a ticket and a patch. I don't remember the ticket > number, but it's probably easy to find, look for "order_by". > > Hope that helps a bit, > > Michael > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100http://www.noris.de- The > IT-Outsourcing Company > > Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - > Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: order_by with foreign keys
On Mon, Sep 10, [EMAIL PROTECTED] wrote: > > hi guys, > i noticed there have been questions about this before, but none of > those threads was helpful. > > i've got a simple db-request, the result should be ordered by a column > "thema" in a foreign key table "Thema": > Test.objects.select_related().order_by("my_app_thema.thema"): That's a known bug with a ticket and a patch. I don't remember the ticket number, but it's probably easy to find, look for "order_by". Hope that helps a bit, Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
order_by with foreign keys
hi guys, i noticed there have been questions about this before, but none of those threads was helpful. i've got a simple db-request, the result should be ordered by a column "thema" in a foreign key table "Thema": Test.objects.select_related().order_by("my_app_thema.thema"): this produces the following error: Column my_app_thema.thema_id does not exist at character 1105 why is that? clearly i don't want django to look for the column "thema_id", instead i want it to look for "thema", so where did i go wrong? the models for this: class Test(models.Model): title = models.CharField(maxlength=120) thema = models.ForeignKey(Thema) class Thema(models.Model): thema = models.CharField(maxlength=90) any help would be greatly appreciated ;) --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: order_by with Foreign Keys
Hmm... the site hangs forever in Apache 2.x when I try this...I've emailed the branch developer to ask if there is a known issue w/ select_related... hopefully I can get it worked out ;) --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: order_by with Foreign Keys
I found this patch which fixes it. I've been using it for a while now: http://code.djangoproject.com/ticket/2210 Honza Král wrote: > this works fine, but if you forget the select_related() it will result > in a cross join which is probably the last thing you want from your > database... > > I was bitten by this when I specified this sort of ordering in the model... > > On 1/13/07, gordyt <[EMAIL PROTECTED]> wrote: > > > > Hi Carole, > > > > There is a workaround for this problem. I am using the latest > > subversion build of django, so I don't know if it works with the last > > official build or not. > > > > Here is an example: > > > > ProductVersion.objects.select_related().order_by("kindledb_product.name","version_number") > > > > Here are the model definitions: > > > > class ProductVersion(models.Model): > > product=models.ForeignKey(Product) > > version_number=models.CharField(maxlength=16) > > availability_date=models.DateField(null=True,blank=True) > > release_notes=models.TextField(blank=True) > > > > class Product(models.Model): > > name=models.CharField(maxlength=128) > > > > > > Note that kindledb_product is the name of the database table that > > stores the information from the Product. > > > > --gordon > > > > > > > > > > > > -- > Honza Král > E-Mail: [EMAIL PROTECTED] > ICQ#: 107471613 > Phone: +420 606 678585 --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: order_by with Foreign Keys
this works fine, but if you forget the select_related() it will result in a cross join which is probably the last thing you want from your database... I was bitten by this when I specified this sort of ordering in the model... On 1/13/07, gordyt <[EMAIL PROTECTED]> wrote: > > Hi Carole, > > There is a workaround for this problem. I am using the latest > subversion build of django, so I don't know if it works with the last > official build or not. > > Here is an example: > > ProductVersion.objects.select_related().order_by("kindledb_product.name","version_number") > > Here are the model definitions: > > class ProductVersion(models.Model): > product=models.ForeignKey(Product) > version_number=models.CharField(maxlength=16) > availability_date=models.DateField(null=True,blank=True) > release_notes=models.TextField(blank=True) > > class Product(models.Model): > name=models.CharField(maxlength=128) > > > Note that kindledb_product is the name of the database table that > stores the information from the Product. > > --gordon > > > > > -- Honza Král E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: order_by with Foreign Keys
Hi Carole, There is a workaround for this problem. I am using the latest subversion build of django, so I don't know if it works with the last official build or not. Here is an example: ProductVersion.objects.select_related().order_by("kindledb_product.name","version_number") Here are the model definitions: class ProductVersion(models.Model): product=models.ForeignKey(Product) version_number=models.CharField(maxlength=16) availability_date=models.DateField(null=True,blank=True) release_notes=models.TextField(blank=True) class Product(models.Model): name=models.CharField(maxlength=128) Note that kindledb_product is the name of the database table that stores the information from the Product. --gordon --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
order_by with Foreign Keys
I've seen a few posts that this was a bug where you cannot specify order_by with a column from a foreign key ... order_by(foreignkeytable__foreignkeycolumn) because it says table not found. Does anyone know if there are plans to fix this...or if there is a work around? I have several resultsets where I have columns from several different tables (related by foreignkeys) and I would like to be able sort on those columns. I had originally just had a javascript function to do it on my table...but now I've added a paginator into the mix...and need to actual order the result set. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---