#2121: Invalid SQL generated when using ordering with search_fields
-------------------------------+--------------------------------------------
 Reporter:  [EMAIL PROTECTED]  |       Owner:  adrian    
     Type:  defect             |      Status:  new       
 Priority:  high               |   Milestone:            
Component:  Database wrapper   |     Version:  SVN       
 Severity:  major              |    Keywords:  sql, admin
-------------------------------+--------------------------------------------
 I have a model as such
 
 
 {{{
 class Discussion(models.Model):
     topic = models.CharField(maxlength=200)
     body = models.TextField()
     person = models.ForeignKey(Person, null=False)
     team = models.ForeignKey(Team, null=False)
 
     def __str__(self):
        return self.team.__str__() + " thread " + self.topic
 
     class Admin:
        list_per_page = 100
        list_display = ('team', 'topic', 'person', 'body', )
        list_filter = ('team', )
        ordering = ('team', 'topic', 'person')
        search_fields = ('body', 'topic')
 }}}
 If I do a search for anything I get an error as such
 {{{
 ProgrammingError at /admin/mrt/discussion/
 ERROR: missing FROM-clause entry for table "mrt_team" SELECT
 
"mrt_discussion"."id","mrt_discussion"."topic","mrt_discussion"."body","mrt_discussion"."person_id","mrt_discussion"."team_id"
 FROM "mrt_discussion" WHERE ((("mrt_discussion"."body" ILIKE '%tim%' OR
 "mrt_discussion"."topic" ILIKE '%tim%'))) ORDER BY "mrt_team"."id" ASC
 }}}
 
 Because it's trying to order by mrt_team which is not part of the select.
 This needs to be remedied

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2121>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to