Re: Ordering by foreign key object field

2008-12-21 Thread sunn
Thanks! On Dec 22, 10:16 am, Malcolm Tredinnick wrote: > On Sun, 2008-12-21 at 23:07 -0800, sunn wrote: > > [...] > > > I would like to order my Block objects by first page.sortorder and > > then sortorder. Any idea on how to accomplish this? > > I have tried with ordering = ['page.sortorder', '

Re: Ordering by foreign key object field

2008-12-21 Thread Malcolm Tredinnick
On Sun, 2008-12-21 at 23:07 -0800, sunn wrote: [...] > I would like to order my Block objects by first page.sortorder and > then sortorder. Any idea on how to accomplish this? > I have tried with ordering = ['page.sortorder', 'sortorder'] but this > does not work ("ordering" refers to "page.sorto

Ordering by foreign key object field

2008-12-21 Thread sunn
from django.db import models class Page(models.Model): sortorder = models.IntegerField() parent = models.ForeignKey('self', null=True, blank=True) class Meta: ordering = ['sortorder'] def __unicode__(self): return self.display class Block(models.Model): sortor

Re: queryset-refactor: ordering by foreign key with null values

2008-05-01 Thread hotani
I changed the query from an "inner join" to "left outer join" which returned issues with null resolutions. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dja

queryset-refactor: ordering by foreign key with null values

2008-05-01 Thread hotani
In a helpdesk app, I have a model called 'issue' which has a foreign key called 'resolution'. The 'resolution' model allows null values - if an issue is open, 'resolution' will be null, if closed, there will be a value there. Before queryset-refactor, I could do the following and get results sort

Re: Ordering by Foreign Key in Admin

2008-03-02 Thread Malcolm Tredinnick
On Sun, 2008-03-02 at 09:38 -0800, watusee wrote: > Thanks for you quick and helpful reply Malcolm! A few clarifications > if I may. I couldn't quite figure out how to connect what the admin > tool does to seeing queries in connection.queries. I can however see > the the offending query when I ge

Re: Ordering by Foreign Key in Admin

2008-03-02 Thread watusee
Thanks for you quick and helpful reply Malcolm! A few clarifications if I may. I couldn't quite figure out how to connect what the admin tool does to seeing queries in connection.queries. I can however see the the offending query when I get an error in the admin. If I do see a query that is not wh

Re: Ordering by Foreign Key in Admin

2008-03-01 Thread Malcolm Tredinnick
On Sat, 2008-03-01 at 20:02 -0800, watusee wrote: > Using the manual Many to Many model as follows in revision 7188 [...] > # > > I've done a lot of searching but can't quite figure out if this is > something that: > > a) Should work in said revision and

Ordering by Foreign Key in Admin

2008-03-01 Thread watusee
Using the manual Many to Many model as follows in revision 7188 # class Book(models:Model): name = models.CharField(max_length=64) class Admin: pass class Author(models:Model): name = models.CharField(max_length=64) class Admin: pass class B

Re: Ordering by foreign key, class Meta

2007-11-13 Thread Malcolm Tredinnick
On Wed, 2007-11-14 at 00:00 +, Michael wrote: > Thanks Malcolm, this helped me on one problem I had. But, I've > another similar problem but in my case, I've multiple foreign keys, so > I'm not sure what to do about the database table name part. > > My models: > class Member(models.Model):

Re: Ordering by foreign key, class Meta

2007-11-13 Thread Michael
Thanks Malcolm, this helped me on one problem I had. But, I've another similar problem but in my case, I've multiple foreign keys, so I'm not sure what to do about the database table name part. My models: class Member(models.Model): # first_name, last_name, etc. class Meta: ordering

Re: Ordering by foreign key, class Meta

2007-11-04 Thread Brot
On Oct 19, 3:11 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2007-10-19 at 06:54 -0700, äL wrote: > > I would like to order a list in a view by foreign key. If I try > >orderinghow in the > > code below my list is ordered by 'person'. And this means that the > > list > > ist order

Re: Ordering by foreign key, class Meta

2007-10-19 Thread Malcolm Tredinnick
On Fri, 2007-10-19 at 06:54 -0700, äL wrote: > I would like to order a list in a view by foreign key. If I try > ordering how in the > code below my list is ordered by 'person'. And this means that the > list > ist ordered by the ID of the table Person. But I need a list ordered > by 'nameLast'. >

Ordering by foreign key, class Meta

2007-10-19 Thread äL
I would like to order a list in a view by foreign key. If I try ordering how in the code below my list is ordered by 'person'. And this means that the list ist ordered by the ID of the table Person. But I need a list ordered by 'nameLast'. Thus I changed ordering 'person' into 'person.nameLast'. B

class Meta: ordering by foreign key

2006-10-10 Thread frank h.
is it possible? I am on the latest trunk, 0.96-pre... in the admin class, I can fake ordering by a foreign key field using the table name and list_select_related class Admin: list_select_related = True ordering = ['myapp_mytable.myfield'] the same does no

class Meta: ordering by foreign key

2006-08-31 Thread frank h.
is it possible? in the admin class, I can fake ordering by a foreign key field using the table name and list_select_related class Admin: list_select_related = True ordering = ['myapp_mytable.myfield'] the same does not seem to work for class Meta, which g

Re: ordering by foreign key

2006-05-22 Thread Joseph Kocherhans
On 5/22/06, Douglas Campos <[EMAIL PROTECTED]> wrote: > i have a model formed by : > vendor = foreign key > name, ver, rev, etc > > how can i order by vendor first? > ordering = [ 'vendor', 'name' ] fails > > any ideas? Ordering by a foreign key isn't technically supported at this point, but you

ordering by foreign key

2006-05-22 Thread Douglas Campos
i have a model formed by : vendor = foreign key name, ver, rev, etc how can i order by vendor first? ordering = [ 'vendor', 'name' ] fails any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" g

Solved: Table not found error when ordering by foreign key

2006-03-19 Thread jtm
My original question (http://groups.google.com/group/django-users/browse_frm/thread/1581881fb9c1ddc1/#): Here is a simplified version of what I am trying to do: App X: class A: shortname = meta.CharField(maxlength=6) App Y: class B: the_A = meta.ForeignKey(A) Y.views: blist = bs.get_li

Re: Table not found error when ordering by foreign key

2006-03-16 Thread jtm
Hi Adrian, Thanks for the reply. I did try using the full table names without success. This is the error and traceback (with real class names): OperationalError at /debtors/current/ (1109, "Unknown table 'matterlist_matters' in order clause") Traceback (most recent call last): File "/opt/lo

Re: Table not found error when ordering by foreign key

2006-03-16 Thread Adrian Holovaty
On 3/13/06, jtm <[EMAIL PROTECTED]> wrote: > Y.views: > blist = bs.get_list(order_by=['as.shortname']) > > But Django is telling me that there is no table named 'as'. > Everything seems to be importing fine. Does anyone have any > hints? Go into your database command-line client and type "\dt" (P

Table not found error when ordering by foreign key

2006-03-12 Thread jtm
Here is a simplified version of what I am trying to do: App X: class A: shortname = meta.CharField(maxlength=6) App Y: class B: the_A = meta.ForeignKey(A) Y.views: blist = bs.get_list(order_by=['as.shortname']) But Django is telling me that there is no table named 'as'. Everything seem

Re: Ordering by foreign key results in FieldDoesNotExist-Error

2005-09-13 Thread Andreas
Hi Jacob, thanks, it's good to know that I'm not going to find the bug in my code. While trying different things, I too found out that adding the "ordering"-option made the listview work again. The first thing I tried was adding ordering = ['theparent']: class FirstChild(meta.Model):

Re: Ordering by foreign key results in FieldDoesNotExist-Error

2005-09-13 Thread Jacob Kaplan-Moss
Hey Andreas -- I actually ran into this same problem myself today. It appears to be a bug in the admin changelist view; until I get a chance to actually track it down you can work around it by adding a "ordering" option to your META.admin:: class FirstChild(meta.Model): ...

Ordering by foreign key results in FieldDoesNotExist-Error

2005-09-13 Thread Andreas
I'm trying to order a class by its parent, but apparently I'm doing something wrong. The code I use: class ParentClass(meta.Model): somevar= meta.CharField(maxlength=100) def __repr__(self): return self.somevar class META: admin = meta.Admin() ord