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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:44:39+00:00 2026-05-16T20:44:39+00:00

This code: import datetime d_tomorrow = datetime.date.today() + datetime.timedelta(days=1) class Model(models.Model): … timeout =

  • 0

This code:

import datetime
d_tomorrow = datetime.date.today() + datetime.timedelta(days=1)

class Model(models.Model):
    ...
    timeout = models.DateTimeField(null=True, blank=True, default=d_tomorrow)
    ...

resuls in this error:

'datetime.date' object has no attribute 'date'

What am I doing wrong?

  • 1 1 Answer
  • 1 View
  • 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-16T20:44:40+00:00Added an answer on May 16, 2026 at 8:44 pm

    Problem solved:

    from datetime import datetime, time, date, timedelta
    def tomorrow():
        d = date.today() + timedelta(days=1)
        t = time(0, 0)
        return datetime.combine(d, t)
    

    models.DateTimeField expects the value to be datetime.datetime, not datetime.date

    2015 Update:

    Arrow makes this all much more straight forward.

    Arrow is a Python library that offers a sensible, human-friendly approach to creating, manipulating, formatting and converting dates, times, and timestamps. It implements and updates the datetime type, plugging gaps in functionality, and provides an intelligent module API that supports many common creation scenarios. Simply put, it helps you work with dates and times with fewer imports and a lot less code.

    Arrow is heavily inspired by moment.js and requests.

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

Sidebar

Related Questions

This is my code: import datetime today = datetime.date.today() print(today) This prints: 2008-11-22 which
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
with this code: import wx import wx.aui class MyFrame(wx.Frame): def __init__(self, parent, id=-1, title='wx.aui
Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame
I ran into unbound method error in python with this code: import random class
Specifically I have code that simplifies to this: from datetime import datetime date_string =
The Problem This code #!/usr/bin/env python import pynotify import time import datetime c='5/1/12 1:15
i have this code from t he django sample tutorial from django.db import models
I have the following python code: from django.db import models from datetime import datetime
I have this code : >>> import datetime >>> l = '2011-12-02' >>> t

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.