title: Flask-Login: Errors With Specific Attributes
body: <p>I'm trying to create and use a User function that works with Flask-Login as follows: </p>
  
  <pre><code>class User(db.Model):
      username = db.Column(db.String(80), primary_key=True)
      passhash = db.Column(db.String(160))
      posts = db.relationship('Idea', backref='user')
  
      def __init__(self, username, password):
          self.username = username
          self.passhash = generate_password_hash(password)
  
      def __str__(self):
          return "User: " + self.username + " Hash: " + self.passhash
  
      # Managing passwords using Werkzeug security library
      def check_password(self, password):
          return check_password_hash(self.passhash, password)
  
      # Necessary functions for Flask-Login session management
      def is_authenticated(self):
          return True
  
      def is_active(self):
          return True
  
      def is_anonymous(self):
          # Anonymous users aren't supported
          return False
  
      def get_id(self):
          return unicode(self.username)
  </code></pre>
  
  <p>However, when trying to use this code, I see the error:</p>
  
  <blockquote>
    <p>AttributeError: 'User' object has no attribute 'is_active'</p>
  </blockquote>
  
  <p>Coming across <a href="https://stackoverflow.com/a/26608805/1195935">this answer</a>, I tried to fix this by changing the function from <code>class User(db.Model)</code> to <code>class User(db.Model, UserMixin)</code>, even though I'm manually implementing the methods. While doing this eliminated the above error, I started seeing:</p>
  
  <blockquote>
    <p>NotImplementedError: No <code>id</code> attribute - override <code>get_id</code></p>
  </blockquote>
  
  <p>What am I doing wrong here? While I don't have an attribute named <code>id</code>, I have set up the <code>get_id</code> function (as above). Is there a particular reason why the functions above aren't being picked up?</p>
  
  <p>The errors occur in particular when I pass my <code>user = User.query.get(form.username.data)</code> to <code>login_user()</code>.</p>