Esempio n. 1
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(200))
    content = db.Column(db.String(300))
    date_created = db.Column(db.DateTime,
                             nullable=False,
                             default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
Esempio n. 2
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    title = db.Column(db.String(200))
    content = db.Column(db.String(300))
    Date_created = db.Column(db.DateTime , nullable = False, default = datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable = False)

    def __repr__(self):
        return "The Title is {} and the user is {}".format(self.title,self.user_id)
Esempio n. 3
0
class Post(db.Model):
     id = db.Column(db.Integer, primary_key = True) 
     title = db.Column(db.String(200))
     content = db.Column(db.String(300))
     date_created = db.Column(db.DateTime, nullable = False, default = datetime.utcnow)
     user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable = False) # Because of the relationship based on the user model; we're saying we have a relationship with the Post Class and User Class showing us which post was made by which user. 
     # Relationship between user and post: user can make many posts but a post is associated with only user
     # USER_ID => 1
     # POST_ID: 23 => Created by USER_ID: 1  

     def __repr__(self):
        return "The Title is {} and the user is {}".format(self.title,self.user_id) # Printing something out to the console everytime a new post is created