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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:03:51+00:00 2026-06-04T17:03:51+00:00

When I save a value for datetime through a POST request, it gets saved

  • 0

When I save a value for datetime through a POST request, it gets saved in the database (I verify by logging the value by quering for it afterwards). But when I reload my page, the value is set to 0000-00-00 00:00:00

# models.py
class Assignment(models.Model):   
  temp = models.CharField(max_length = 32)
  deadline = models.DateTimeField(default=lambda: datetime.datetime.now() + datetime.timedelta(days=14))

# views.py
def some_function(request):
  deadline = request.POST['deadline']
  assignment.deadline = datetime.timedelta(int(deadline)) + datetime.datetime.now()

When I log the assignment.deadline value throughout this function, it’s always what I expect it to be (the current date + whatever the value in the POST request was).
However, when the page reloads, the value is set back to 0000-00-00 00:00:00

Why is this happening?

  • 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-06-04T17:03:52+00:00Added an answer on June 4, 2026 at 5:03 pm

    Aren’t you forgetting to call your assignment’s save() method?

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

Sidebar

Related Questions

I am doing this to save a DateTime in the MySQL database but when
I'm trying to save date (using C# official driver): val = DateTime.Parse(value).Date; //Here date
Database : SQLite Column : SomeTable.Logged (DateTime) Im using the System.Data.SQLite component. I save
I have SQL Server database entry LastCheck of datatype DateTime . By first save
I want to save entries to a database table depending on the DateTime entered.
I use Microsoft SQL server to save and retrieve DateTime . But in our
I have to save the ID of a selected item into the database. but,
View def editor(request): form = SessionForm(initial={ 'end_time': datetime.datetime.now(), }) if request.method == 'POST': form
Widget tk.Entry from example_script.py do not save value 'textvariable' field. example_script.py: import Tkinter as
I Want to save the value of an inplace if it was changed. The

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.