notion-py
notion-py copied to clipboard
TypeError: Object of type NotionDate is not JSON serializable
trying to add a new row and populate a date but I'm getting a type error
here is my code where I'm trying to assign a DateTime object in my list to the date property of the new row
cv = client.get_collection_view(page)
row = cv.collection.add_row()
row.Due = Canvas.assignment_details_list[0][1]
tried to use datetime.now()
instead of what was in my list and I still get the same TypeError
not sure if I'm assigning the date property the wrong way or if its something else but any help with this is appreciated
I've got the same error
Can you share how the row.Due
is done?
Also i think it should be due
(lowercase)
so im grabbing a string from canvas and I'm parsing it.
then I use the .striptime
method from datetime to convert the string to a datetime format.
here is the code for how I parse and save the data for the date.
x = attributes_dump.find('due_at')
if x != -1:
z = attributes_dump.find(',',x)
due_at_date = str(attributes_dump[x+len('due_at='):z])
due_at_date = due_at_date.replace('T', ' ')
due_at_date = due_at_date.replace('Z', '')
# if there is a due date format and cast it to a datetime object
try:
due_at_date = datetime.strptime(due_at_date+'.0', '%Y-%m-%d %H:%M:%S.%f')
except:
pass
Okay, can you try to use
row.due = NotionDate(get_your_date)
For me this did the Trick
You Fund notion date inside the collection package
so I did that and now im not getting an error but now the date field is not being populated with the data I want.
even when I use date.today
Hm, weird, than i have no clue, how to solve this