title: Flask-login current_user returns only ID
body: <p>I've managed to get flask-login working but when I try use, for example <code>current_user.username</code> in my templates the value is <code>None</code></p>
  
  <p>I suspect this is to do with my User.get() function but cannot for the life of my understand what I need to do so I can access the current users <code>username</code> or <code>email</code> and so on.</p>
  
  <p>So the question is, why are the rest of my current_user attributes like <code>username</code>, not getting populated?</p>
  
  <h2>models.py</h2>
  
  <p>Note the get function</p>
  
  <pre><code>from sqlalchemy import Column, Integer, String
  from flask_login import UserMixin
  
  from database import Base
  
  
  class User(Base, UserMixin):
      __tablename__ = 'users'
      id = Column(Integer, primary_key=True)
      username = Column(String(80), unique=True)
      password = Column(String(80))
      email = Column(String(120), unique=True)
  
      def __init__(self, id):
          self.id = id
  
      def __repr__(self):
          return '&lt;User %r&gt;' % self.username
  
      @classmethod
      def get(cls, id):
          """Return user instance of id, return None if not exist"""
          try:
              return cls(id)
          except UserWarning:
              return None
  </code></pre>
  
  <h2>views.py</h2>
  
  <p>Note the load_user, I believe the flask documents expect this to be present and for it to take an ID as input</p>
  
  <pre><code>import flask
  from flask_login import login_user, logout_user, login_required
  
  from reportr import app, login_manager
  from models import User
  from forms import UploadForm, LoginForm
  from database import init_session
  
  
  @login_manager.user_loader
  def load_user(id):
      return User.get(id)
  
  
  @app.route('/', methods=('GET', 'POST'))
  def index():
      return flask.render_template('index.html')
  
  
  @app.route('/login', methods=['GET', 'POST'])
  def login():
      form = LoginForm()
      del form.email  # Don't want the email address on the form
  
      if form.validate_on_submit():
          session = init_session()
          user = session.query(User).filter(User.username == flask.request.form['username']).first()
  
          if user and user.password == flask.request.form['password']:
              login_user(user)
              flask.flash('Logged in successfully.', 'info')
          else:
              flask.flash('Username or password incorrect.', 'error')
  
              return flask.redirect(flask.url_for('login'))
  
          return flask.redirect(flask.url_for('index'))
      return flask.render_template('login.html', form=form)
  
  
  @app.route('/logout')
  def logout():
      logout_user()
  
      return flask.redirect(flask.url_for('index'))
  
  
  @app.route('/upload/results', methods=('GET', 'POST'))
  def upload_results():
      form = UploadForm()
  
      if not form.validate_on_submit():
              flask.flash('Please fill out all required fields', 'error')
  
      return flask.render_template('upload_results.html', form=form)
  
  
  @app.route("/settings")
  @login_required
  def settings():
      pass
  </code></pre>
  
  <h2>templates/nav-bar.html</h2>
  
  <p>In here I am using current_user.id, this works.</p>
  
  <pre><code>{% block navbar %}
  &lt;nav class="navbar navbar-default" role="navigation"&gt;
      &lt;div class="container"&gt;
          &lt;div class="navbar-header"&gt;
              &lt;a class="navbar-brand" href="{{ url_for('.index') }}"&gt;&lt;span class="glyphicon-play" aria-hidden="true"&gt;&lt;/span&gt;Reportr!&lt;/a&gt;
          &lt;/div&gt;
          &lt;div class="navbar-collapse collapse click-nav"&gt;
              &lt;ul class="nav navbar-nav no-js"&gt;
                  &lt;li class="dropdown"&gt;
                      &lt;a id='browse_menu' href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"&gt;Browse &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                      &lt;ul class="dropdown-menu" role="menu"&gt;
                          &lt;li&gt;
                              &lt;a id='browse_by_project' href="#"&gt;By Project&lt;/a&gt;
                          &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;li class="dropdown"&gt;
                      &lt;a id='upload_menu' href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"&gt;Upload &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                      &lt;ul class="dropdown-menu" role="menu"&gt;
                      &lt;li&gt;
                          &lt;a id='upload_test_results' href="{{ url_for('.upload_results') }}"&gt;Test Results&lt;/a&gt;
                      &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
              &lt;ul class="nav navbar-nav navbar-right"&gt;
                  {% if current_user.is_authenticated() %}
                  &lt;li class="dropdown"&gt;
                  &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"&gt;{{ current_user.id }} &lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
                      &lt;ul class="dropdown-menu" role="menu"&gt;
                          &lt;li&gt;&lt;a href="{{ url_for('.settings') }}"&gt;Settings&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="divider"&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="{{ url_for('.logout') }}"&gt;Logout&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/li&gt;
                  {% else %}
                  &lt;li&gt;
                      &lt;a id='login' href="{{ url_for('.login') }}"&gt;Login&lt;/a&gt;
                  &lt;/li&gt;
                  {% endif %}
              &lt;/ul&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  {% endblock %}
  </code></pre>