title: Python interpreter not returning user info correctly in Flask tutorial
body: <p>I am doing Miguel grinberg's flask tutorial and on step 4 Database. 
  <a href="http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database" rel="nofollow">http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database</a></p>
  
  <p>In this step, in the playtime section, when I open python interpreter from virtual env and type in the commands for adding a user:</p>
  
  <pre><code>&gt;&gt; from app import db,models
  &gt;&gt; u= models.User(nickname='john', email='john2@gmail.com')
  &gt;&gt; db.session.add(u)
  &gt;&gt; db.session.commit()
  </code></pre>
  
  <p>Now to retrieve the user info I did the following:</p>
  
  <pre><code>&gt;&gt; users= models.User.query.all()
  &gt;&gt; users
  </code></pre>
  
  <p>and instead of returning <code>[&lt;User u'john'&gt;]</code> I am getting: </p>
  
  <pre><code>[&lt;app.models.User object at 0xb74bd1ac&gt;] 
  </code></pre>
  
  <p>which seems like I am returned the memory location of John rather than actual name. So what am I doing wrong? Any suggestion?</p>
  
  <p>My code for models.py: </p>
  
  <pre><code>from app import db 
  
  class User(db.Model):
      id = db.Column(db.Integer,primary_key= True)
      nickname = db.Column(db.String(64),index= True,unique= True)
      email = db.Column(db.String(120),index= True,unique= True)
      posts = db.relationship('Post',backref= 'author', lazy='dynamic')
  
      def _repr_(self):
          return '&lt;User %r&gt;'% (self.nickname)
  
  
  class Post(db.Model):
      id = db.Column(db.Integer, primary_key= True)
      body = db.Column(db.String(140))
      timestamp = db.Column(db.DateTime)
      user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
  
      def _repr_(self):
          return '&lt;Post %r&gt;' % (self.body)
  </code></pre>
  
  <p>code for db_create.py: </p>
  
  <pre><code>#!flask/bin/python
  from migrate.versioning import api
  from config import SQLALCHEMY_DATABASE_URI
  from config import SQLALCHEMY_MIGRATE_REPO
  from app import db
  import os.path
  db.create_all()
  if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
      api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
      api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
  else:
      api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
                          api.version(SQLALCHEMY_MIGRATE_REPO))
  </code></pre>
  
  <p>code for db_migrate.py: </p>
  
  <pre><code>#!flask/bin/python
  import imp
  from migrate.versioning import api
  from app import db
  from config import SQLALCHEMY_DATABASE_URI
  from config import SQLALCHEMY_MIGRATE_REPO
  v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
  migration = SQLALCHEMY_MIGRATE_REPO + ('/versions/%03d_migration.py' % (v+1))
  tmp_module = imp.new_module('old_model')
  old_model = api.create_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
  exec(old_model, tmp_module.__dict__)
  script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI,
                                            SQLALCHEMY_MIGRATE_REPO,
                                            tmp_module.meta, db.metadata)
  open(migration, "wt").write(script)
  api.upgrade(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
  v = api.db_version(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
  print('New migration saved as ' + migration)
  print('Current database version: ' + str(v))
  </code></pre>
  
  <p>Also to clarify, I have followed all the steps till now in all 4 parts of the tutorial. working on it in Ubuntu 16.04 vmware version. Any help will be appreciated. Thanks in advance! </p>