You are probably not importing the datetime class from datetime module correctly . Either import it using:

from datetime import datetime

or use:

import datetime

and then

datetime.datetime(...)