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

  • SEARCH
  • Home
  • 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 7165857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:19:10+00:00 2026-05-28T14:19:10+00:00

With Django I have this model: class downloads(models.Model): date = models.CharField(max_length=50) ip = models.ForeignKey(IPaddress)

  • 0

With Django I have this model:

class downloads(models.Model):
date = models.CharField(max_length=50)
ip = models.ForeignKey(IPaddress)
partnum = models.ForeignKey(partnum)
user = models.ForeignKey(userinfo)
filename = models.CharField(max_length=128)
issueId = models.ForeignKey(issueInfo)

What I need to do is to get data from that table where the date is > date 1 and < date2

I know if I was using PHP I could query the db to do something like select * from downloads where date > date1 and date < date2 which would ofc give me a dataset to iterate through, How do I go about this using Django?

I am going to take a wild stab in the dark and ask is it something like this:

d = downloads.objects.get('Where date > date1 and date < date2')

or

d = downloads.objects.get(date=>date1,date<=date2)

I am very new to python and Django (started to learn it last week…) and any help would be brilliant.

Thanks

Edit: Thanks for the quick replys – worked out the answer to my new question

  • 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-28T14:19:11+00:00Added an answer on May 28, 2026 at 2:19 pm

    If you are using Django ORM then do the following:

    downloads = Downloads.objects.filter(date__range=(dat1, date2))
    

    or

    downloads = Downloads.objects.filter(date__gt=date1, date__lt=date2)
    

    This will filter your objects accordingly. __gt means “greater than” and __lt means “less than”.

    Read the documentation for further clarification:
    https://docs.djangoproject.com/en/dev/ref/models/querysets/#filter

    https://docs.djangoproject.com/en/dev/ref/models/querysets/#gt

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

Sidebar

Related Questions

I have this model: class blog(models.Model): user = models.ForeignKey(User) mail = models.EmailField(max_length=60, null=False, blank=False)
Let's say I've defined this model: class Identifier(models.Model): user = models.ForeignKey(User) key = models.CharField(max_length=64)
I have the following model in django: class Node(models.Model): name = models.CharField(max_length=255) And this
I have the following Django model: class opetest(models.Model): name = models.CharField(max_length=200) people = models.ManyToManyField(User,
I have this models in Django class Country(models.Model): name = models.CharField(max_length=80) class Person(models.Model): first_name
I have this Django model: class Lecture(models.Model): lecture_number = models.CharField(_('lecture number'), max_length=20) title =
I have this Django model (from Django CMS): class Placeholder(models.Model): slot = models.CharField(_(slot), max_length=50,
I have this Model in django : class Post(models.Model): title = models.CharField(max_length=255) category =
I have this model in django: class JournalsGeneral(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code,
I currently have this chunk of model code: class Book(models.Model): title = models.CharField(max_length=100) num_pages

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.