I'm writing a custom Manager to only return objects which fall within
dates set for Active From and Active To fields.  It currently looks
like this:

class ActiveManager(models.Manager):
  def get_query_set(self):
    objects = super(ActiveManager, self).get_query_set()
    objects = objects.exclude(active_from__lt = datetime.datetime.today())
    objects = objects.exclude(active_to__gt = datetime.datetime.today())
    return objects

Here's the gotchya though: if either of those dates aren't set, I want
the object to still be returned.  i.e. if Active From isn't set, then
it's date should be treated as the beginning of time.

An easy fix would be for me to make these required fields, but I'd
quite like them to be optional.  Is there any way I can do this
without writing a custom query?

-Phil

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to