Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4033076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:48:07+00:00 2026-05-20T11:48:07+00:00

I need to find data within a certain set of parameters I am building

  • 0

I need to find data within a certain set of parameters
I am building a small booking system, that lets user see what vehicles are available for booking for their little safari trip.

The system has bookings that have been entered previously or made previously by a client.

If a booking’s pickup_date = 2011-03-01 and dropoff_date = 2011-03-15 and I run a query with pickup=2011-03-09 and dropoff=2011-03-14 in my views as below, it doesn’t return any results to see if a booking within that timeframe has been made.

views.py

def dates(request, template_name='groups/_dates.html'):
    pickup=request.GET.get('pickup','None');
    dropoff=request.GET.get('dropoff','None');
    order = Order.objects.filter(pick_up__lte=pickup).filter(drop_off__gte=dropoff)

    context = {'order':order,}

    return render_to_response(template_name,context,
        context_instance=RequestContext(request))

Any suggestions on how to do this?
Or should I be looking at an alternate way of running this query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:48:08+00:00Added an answer on May 20, 2026 at 11:48 am

    Could it be posible that as your passing the raw string to the queryset is not on the correct format, try converting the strings to datetime objects.

    Later you can try using the range lookup is more efficient on some DB engines and more simple to read and code.

    from django.db.models import Q
    
    start_date = datetime.date(2005, 1, 1)
    end_date = datetime.date(2005, 3, 31)
    orders = Order.objects.filter(drop_off__gte=start_date, pick_up__lte=end_date)
    # Or maybe better
    orders = Order.objects.filter(Q(drop_off__gte=start_date), Q(pick_up__lte=end_date))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several tables that contain multipolygons. I need to find points within these
I am trying to find data within a HTML document. I don't need a
Consider the need to query for a certain pattern of data within a column.
I have a table of time-series data of which I need to find all
Consider I have a data grid, I need to find the number of rows
I need to find/create an application that will create employee web usage reports from
I need to find occurrences of ~ 25 000 words within a text. What
How can I use regex to find everything except for data within div with
I need to store 2 dimensional data, that is points (x,y) in a database.
I need to find a solution that holds and accesses large chunks of complex

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.