0

Am getting this error while updating date field to null in Django." 'Null' value has an invalid date format. It must be in YYYY-MM-DD format". Please help me if any one knows the solution.

Code: if editBirthday: editBirthday=datetime.strptime(str(editBirthday),"%d-%m-%Y").strftime("%Y-%m-%d") loggedInUser.Birthday = editBirthday else: loggedInUser.Birthday = "Null"

user3539644
  • 3
  • 1
  • 5
  • 2
    Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the [How to Ask](http://stackoverflow.com/help/how-to-ask) page for help clarifying this question. – Paulo Scardine Apr 16 '14 at 04:50
  • At the time of user profile creation he given the dateofbirth but in edit profile if he wants to remove the dob from details.At that time i am trying to update dob to null into table.Then am getting this error. – user3539644 Apr 16 '14 at 04:56

1 Answers1

1

You should not set the value to "null", set it to None:

loggedInUser.Birthday = None
loggedInUser.save()

For this to work Birthday model field show be defined with null=True.

See also:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195