title: How to add admin using flask_pymongo and flask_admin
body: <p>How to add admin using flask_pymongo and flask_admin</p>
  
  <p>```</p>
  
  <pre><code>from flask import Flask
  from flask_pymongo import PyMongo
  
  from bson import json_util
  
  from bson.objectid import ObjectId
  import flask_admin as admin
  
  from wtforms import form, fields
  
  from flask_admin.form import Select2Widget
  from flask_admin.contrib.pymongo import ModelView, filters
  from flask_admin.model.fields import InlineFormField, InlineFieldList
  from flask_pymongo import PyMongo
  
  # app settings
  app = Flask(__name__)
  
  app.config['MONGO_URI'] = 'mongodb://username:passwrod@ds156811.mlab.com:56811/somedb'
  app.config['MONGO_CONNECT'] = True
  app.secret_key = 'secret'
  
  mongo = PyMongo(app)
  db = mongo
  
  
  class UserForm(form.Form):
      name = fields.StringField('Name')
      email = fields.StringField('Email')
  
  class UserView(ModelView):
      column_list = ('name', 'email')
      form = UserForm
  
  admin = admin.Admin(app)
  
  
  admin.add_view(UserView(db['users']))
  </code></pre>
  
  <p>```</p>
  
  <p>Here is small example taken from <a href="https://flask-admin.readthedocs.io/en/v1.0.9/db_pymongo/" rel="nofollow noreferrer">https://flask-admin.readthedocs.io/en/v1.0.9/db_pymongo/</a>
  Here is another:
  <a href="https://github.com/flask-admin/flask-admin/tree/master/examples/pymongo" rel="nofollow noreferrer">https://github.com/flask-admin/flask-admin/tree/master/examples/pymongo</a></p>
  
  <p>The flask-admin community has used <code>pymongo</code> but I want to use flask-pymongo package.</p>
  
  <p>I am okay with most of the code but adding of view to the admin page is creating problem, <code>admin.add_view()</code> function is creating problem. </p>
  
  <p>The question is <strong>how to add view to admin page, by taking flask-admin and flask-pymongo(pymongo is different)?</strong></p>
  
  <p><strong>Edited</strong>:
  error message:</p>
  
  <pre><code>TypeError: 'PyMongo' object is not subscriptable
  </code></pre>
  
  <p>The object we get using the pymongo is different from what we get from pyflask-mongo, which is being responsible for the problem.</p>