def new_post(self):
        tittle = input("Enter post Tittle: ")
        content = input("Enter post Content: ")
        date = input("Enter post date, or leave blank for today (in format DDMMYYYY ): ")
        if date == "":
            date = datetime.datetime.utcnow() # put localmachineDate in Date with DateFormat
        else:
           date=datetime.datetime.strptime(date, "%d%m%Y") #parse str to DateFormat

        post = Post(blog_id=self.id,
                    tittle=tittle,
                    content=content,
                    author=self.author,
                    date=date)
        post.save_to_mongo()
Ejemplo n.º 2
0
    def new_post(self):
        title = raw_input("Enter post title: ")
        content = raw_input("Enter post content: ")
        date = raw_input(
            "Enter post date, or leave blank for today (in format DDMMYYYY): ")

        if date == "":
            date = datetime.datetime.utcnow()
        else:
            date = datetime.datetime.strptime(date, "%d%m%Y")

        post = Post(blog_id=self.id,
                    title=title,
                    content=content,
                    author=self.author,
                    date=date)
        post.save_to_mongo()