#7 Basic flask app. Setup routes, DB, and made a user model. Made initial migrations
This commit is contained in:
21
backend/app/models.py
Normal file
21
backend/app/models.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from app import db
|
||||
from flask_login import UserMixin
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class User(UserMixin, db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
username = db.Column(db.String(64), index=True, unique=True)
|
||||
email = db.Column(db.String(120), index=True, unique=True)
|
||||
password_hash = db.Column(db.String(128))
|
||||
about_me = db.Column(db.String(140))
|
||||
last_seen = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
token = db.Column(db.String(32), index=True, unique=True)
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"username": self.username,
|
||||
"email": self.email,
|
||||
"about_me": self.about_me,
|
||||
}
|
||||
Reference in New Issue
Block a user