ON the localhost
# coding: utf8
from gluon import current
from pymongo import MongoClient
from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
from gluon.custom_import import track_changes
track_changes(True)
db = DAL('mongodb://localhost/"db name"')
response.generic_patterns = ['*'] if request.is_local else []
auth = Auth(db, hmac_key=Auth.get_or_create_key())
db.define_table('post',
Field('author', 'reference auth_user', default=auth.user_id, readable=False, writable=False),
Field('message', 'text', requires=IS_NOT_EMPTY(),),
auth.signature
)
controller:
MongoDB
# I use ubuntu 18.04LTS
2. Follow instructions after download
3. It will save in the homepage as folder(called robo3t)
4. In the folder, bin folder, find the robo3t app. Click on it, then click on connect to see your db. See the images attached.
N/B I noted that sometimes the error of 'Null type' comes when accessing the db when no value has been entered/posted. SO post some value and see it in the database with the browser.