Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # app/models.py
- from app import db
- from datetime import datetime
- class UserModel(db.Model):
- __tablename__ = 'users'
- 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 = db.Column(db.String(128), nullable=False)
- registration_date = db.Column(db.DateTime, default=datetime.utcnow)
- def to_dict(self):
- return {
- 'user_id': self.id,
- 'username': self.username,
- 'email': self.email,
- 'registration_date': self.registration_date.isoformat() + 'Z'
- }
Add Comment
Please, Sign In to add comment