Skip to content

Instantly share code, notes, and snippets.

@xraymemory
Created September 17, 2012 19:46
Show Gist options
  • Select an option

  • Save xraymemory/3739358 to your computer and use it in GitHub Desktop.

Select an option

Save xraymemory/3739358 to your computer and use it in GitHub Desktop.
User row
class User(db.Model):
__tablename__ = 'user'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True)
email = db.Column(db.String(120), unique=True)
password = db.Column(db.String(120), unique=True)
biography = db.Column(db.String(300), unique=False)
upvotes = db.Column(db.Integer)
downvotes = db.Column(db.Integer)
responses = relationship("Posts", backref="user")
followed_categories = relationship("Categories",
backref="user")
followed_users = relationship("Users", backref="user")
followed_threads = relationship("Threads",
backref="user")
def __init__(self, username, email, password, biography):
self.username = username
self.email = email
self.password = function_to_encrypt_password_because_plain_text_is_bad(password)
self.biography = biography
self.upvotes = 0
self.downvotes = 0
self.followed_categories = None
self.followed_users = None
self.followed_threads = None
def __repr__(self):
return '<User %r>' % self.username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment