Guest User

Untitled

a guest
May 5th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. # app/models.py
  2.  
  3. from app import db
  4. from datetime import datetime
  5.  
  6. class UserModel(db.Model):
  7. __tablename__ = 'users'
  8.  
  9. id = db.Column(db.Integer, primary_key=True)
  10. username = db.Column(db.String(64), index=True, unique=True)
  11. email = db.Column(db.String(120), index=True, unique=True)
  12. password = db.Column(db.String(128), nullable=False)
  13. registration_date = db.Column(db.DateTime, default=datetime.utcnow)
  14.  
  15. def to_dict(self):
  16. return {
  17. 'user_id': self.id,
  18. 'username': self.username,
  19. 'email': self.email,
  20. 'registration_date': self.registration_date.isoformat() + 'Z'
  21. }
Add Comment
Please, Sign In to add comment