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 878721
In Process

The Archive Base Latest Questions

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

I saw the next two methods in an old question here but it is

  • 0

I saw the next two methods in an old question here but it is not clear for me what is the difference between:

{'date_time_field__range': (datetime.datetime.combine(date, datetime.time.min),
                        datetime.datetime.combine(date, datetime.time.max))}

and

YourModel.objects.filter(datetime_published__year='2008', 
                     datetime_published__month='03', 
                     datetime_published__day='27')
  • 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-15T11:48:38+00:00Added an answer on May 15, 2026 at 11:48 am

    Was confused about this myself, but I think I’ve worked it out 😀 I found the documentation about the range lookup option very helpful.

    When you do:

    YourModel.objects.filter(datetime_published__year='2008', 
                         datetime_published__month='03', 
                         datetime_published__day='27')
    

    The SQL will look something like:

    SELECT ... WHERE EXTRACT('year' FROM pub_date) = '2008'
                 AND EXTRACT('month' FROM pub_date) = '03'
                 AND EXTRACT('day' FROM pub_date) = '27';
    

    Whereas this part of django’s generic date based views:

    {'date_time_field__range': (datetime.datetime.combine(date, datetime.time.min),
                            datetime.datetime.combine(date, datetime.time.max))}
    

    becomes something like:

    YourModel.objects.filter(datetime_published__range=(
                    datetime.datetime.combine('2008-03-27',datetime.time.min),
                    datetime.datetime.combine('2008-03-27',datetime.time.max)
                                                                      )
    

    which produces SQL along the lines of:

    SELECT ... WHERE datetime_published BETWEEN '2008-03-27 00:00:00'
                                            AND '2008-03-27 23:59:59';
    

    (the format of the timestamp in the last SQL example is wrong obviously, but you get the idea)

    Hope that answers your question 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw a similar question being posted here, yet it did not help me
I saw that even by writing separate commands, we can combine two different types
I saw some code when studying the open source project: here . But I
In this question i saw two different answers how to directly call functions written
I saw from another question here : Determine iPhone user's country that it is
I saw that one of our tools uses a ConsoleAppender to System.err next to
I saw the docs on the Instagram developers page. http://instagram.com/developer/endpoints/ But I want to
I saw many threads with this tittle, but no one really speak about reuse
I saw comment If you have 50 million values between 10 and 15 characters
Ive saw the next paragraph in some computer science test and i'll hope i

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.