Re: Date Filtering in Django-Sphinx
On Mar 30, 6:11 am, Alfonsowrote: > > And in my search view I have a simple filter (which is where I think > the problem lies): > > if date == "next30": > results = queryset.filter(date_time>=(datetime.datetime.now)) > > (Attempting to pull future dates just to see something happen) > > Where am I going wrong? Assuming date_time is a field on your model: results = queryset.filter(date_time__gte=datetime.datetime.now()) See the docs on field lookups: http://docs.djangoproject.com/en/dev/topics/db/queries/#field-lookups Also, you want to construct a datetime object that is equal to now, not compare your field to the datetime.datetime.now function. -BN --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Date Filtering in Django-Sphinx
Using sphinx for search in my django app and whilst it's great I can't seem to get any date filtering happening. Sphinx conf is fairly unremarkable: source event_event_en : base { # main document fetch query # mandatory, integer document ID field MUST be the first selected column sql_query = \ SELECT yadda ya..., UNIX_TIMESTAMP(date_time) as date_time, yaddy ya... FROM event_event sql_query_info = SELECT * FROM event_event WHERE id=$id # ForeignKeys sql_attr_uint= category_id sql_attr_uint= venue_id sql_attr_uint= event_type sql_attr_uint= artist_id sql_attr_uint= delivery_days sql_attr_uint= region sql_attr_uint= event_status # DateFields sql_attr_timestamp = date_time } And in my search view I have a simple filter (which is where I think the problem lies): if date == "next30": results = queryset.filter(date_time>=(datetime.datetime.now)) (Attempting to pull future dates just to see something happen) Where am I going wrong? Thanks A --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---