#4681: filter on foreign keys with None doesn't return anything
-----------------------------------------------------+----------------------
Reporter:  Patrick Lauber <[EMAIL PROTECTED]>  |       Owner:  adrian           
     
  Status:  new                                       |   Component:  Core 
framework        
 Version:  SVN                                       |    Keywords:  filter 
foreignkey None
   Stage:  Unreviewed                                |   Has_patch:  0          
           
-----------------------------------------------------+----------------------
 At the moment you have to do it like this:
 {{{
 class Category(models.Model):
     name = models.CharField(core=True, maxlength=64)
     parent = models.ForeignKey('self', blank=True, null=True,
 related_name='child')
 
 def getNavigation(request,parent):
     if parent==None:
         return
 Category.objects.filter(parent__id__isnull=True).order_by('-priority')
     else:
         return
 Category.objects.filter(parent__id=parent).order_by('-priority')
 }}}
 I think for a newbie to Databases like me this not very intuitive.
 Wouldn't it be possible to make the isnull check automatically behind the
 scenes if the argument is None or an empty String?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/4681>
Django Code <http://code.djangoproject.com/>
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to