How to create key in python

I have a problem with the key on a few items and need help. What I have not been able to do is create a key on my website to send back as info. What I want to do as a work around is place

However, When I try and do an api into it. I get an error message saying

("'module' object has no attribute 'datetime'",)

How do I fix this


You are a life saver. Thank you