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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:23:25+00:00 2026-05-27T19:23:25+00:00

I am a starter in Django/Python. I have a model MyModel . It has

  • 0

I am a starter in Django/Python.

I have a model MyModel. It has many fields of datetime, char, integer types. Now, I want a values list which has values of the datetime fields containing only the date parts.

I have tried using the dates function [reference] (https://docs.djangoproject.com/en/1.2/ref/models/querysets/#dates), but it works only with one field. I have multiple datetime fields and all have to be retrieved in the required format.

Basically, I want a Django equivalent of :

select stringfield1, date(datefield1), integerfield1, date(datefield2) from mymodel; (PostGreSQL)

Is this even possible? If it is, how should I proceed further?

  • 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-27T19:23:26+00:00Added an answer on May 27, 2026 at 7:23 pm

    I’m not sure if Django has a builtin way of doing this. You could use itertools.imap to lazily convert the fields in question into date objects:

    from itertools import imap
    values = MyModel.objects.values_list('stringfield1', 'datefield1', 
                                           'integerfield1', 'datefield2')
    values = imap(lambda (s, d1, i, d2): (s, d1.date(), i, d2.date()), values) 
    

    (But note that after this you’re not dealing with a ValuesListQuerySet anymore but with an itertools.imap object.)

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

Sidebar

Related Questions

With Django I have this model: class downloads(models.Model): date = models.CharField(max_length=50) ip = models.ForeignKey(IPaddress)
Imagine you have a web application written in Django and Python 2.65, and MySQL
I have been coding in python/django and c/c++ from last three years for various
I have made an online gallery using Python and Django. I've just started to
I have experience writing web apps in Django; scripting in Python; playing with PHP
I have Django installed. I also have django-admin.py in my python-2.7 folder. I can
I'm new to Django (and Python) and I have been trying to work out
I have django-registration installed. I just updated my Python installation from 2.5 to 2.7.
I just started learning python and django and I have a question. I got
I have been playing with python and different web frameworks. I started with Django,

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.