Last active
December 20, 2015 08:09
-
-
Save detailyang/6098103 to your computer and use it in GitHub Desktop.
flask model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask.ext.sqlalchemy import SQLAlchemy | |
from app import db | |
class User(db.Model): | |
id = db.Column(db.Integer, primary_key = True) | |
username = db.Column(db.String(80), unique = True, | |
index = True, nullable = False) | |
email = db.Column(db.String(120), unique = True, nullable = False) | |
password = db.Column(db.String(100), nullable = False) | |
def __init__(self, **kwargs): | |
if 'username' in kwargs: | |
self.username = kwargs.pop('username') | |
if 'password' in kwargs: | |
self.username = kwargs.pop('password') | |
if 'email' in kwargs: | |
self.username = kwargs.pop('email') | |
def __str__(self): | |
return self.username | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment