init
This commit is contained in:
commit
5309e0593b
22 changed files with 722 additions and 0 deletions
blog/models
17
blog/models/entries.py
Normal file
17
blog/models/entries.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from blog import db
|
||||
from datetime import datetime
|
||||
|
||||
class Entry(db.Model):
|
||||
__tablename__ = 'entries'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
title = db.Column(db.String(50), unique=True, nullable=False)
|
||||
text = db.Column(db.Text, nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
def __init__(self, title, text):
|
||||
self.title = title
|
||||
self.text = text
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Entry id:{self.id} title:{self.title} text:{self.text}>'
|
Loading…
Add table
Add a link
Reference in a new issue