A Django app can be used to query and render MongoDB data
Project description
dj-mongo-reader is a Django application can be used to query MongoDB via AJAX requests and render result with several customization options.
Installation
Install from PyPi pip install dj-mongo-reader
Install from source code
download code git clone https://github.com/feifangit/dj-mongo-reader.git
run <setup.py> from dj-mongo-reader folder python setup.py install
Features
Able to send find, count, collstats commands to MongoDB via designated URL
Basic HTML pages included, only few code is needed to work with your existing CSS framework
Pagination implemented, you can customize record number show in each page
Permission check, you can deny a data fetching request based on user’s permission and the query(database, collection, command, criteria).
Pick up some keys of the record to fill the table, leave complete record in detail dialog
Assign display names for keys in MongoDB record
value transformation, you can provide Javascript callback functions to process raw value data from MongoDB to a proper text for displaying
DEMO
A Django application runs on heroku.
Functionality: A query form and result table included.
UI: Bootstrap 3 applied.
Quick start
add dj-mongo-reader to INSTALLED_APPS in <settings.py>
add JSON-type variable MONGO_READER_SETTINGS in <settings.py>
conn_str, MongoDB connection string, see http://docs.mongodb.org/manual/reference/connection-string/
perm_check_func, a string represent path to a permission verification function
e.g.
MONGO_READER_SETTINGS = { "conn_str": "mongodb://10.1.5.10:27017/2", "perm_check_func": "somewhere.security.my_mongocall_perm_check", }
in file <somewhere/security.py>, we have the permission verification ready
def my_mongocall_perm_check(req, db, col, cmd): u = req.user if (not u) or (not u.is_authenticated()): return False if db != "dbforapp1": # limit db to dbforapp1 return False if not col.startswith("transaction_"): # limit collection to transaction_.* return False q = json.loads(req.GET.get("criteria", "{}")) # limit parameter based on criteria if u.company and u.company.id != int(q.get("company", "-1")): return False return True
URL dispatch
add url route to your <urls.py>
urlpatterns = patterns('', ... url(r'^mongo/', include('dj-mongo-reader.urls')) ...
embed into your own HTML
parameters for dj-mongo-reader/table.html
db
col
cmd
rowcount (optional), default 50
criteria, JSON format
sort, JSON format
columns, string, key names connected by comma
columns_trans (optional), JSON format, a database key name to display name mapping.
5. customize your result page create folder dj-mongo-reader under your templates folder
Credits
Fan Fei feifan.pub@gmail.com backend
Neil Chen neil.chen.nj@gmail.com frontend
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dj-mongo-reader-0.6.tar.gz
.
File metadata
- Download URL: dj-mongo-reader-0.6.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9ab788cd2b69fac006475d26834bb68e3f8d8e6095a723be1616be2de90186f |
|
MD5 | df99f4955df24375c32d16ee1a83f858 |
|
BLAKE2b-256 | c6e609e007d4b04cc7b3cc20061b8d2eb060416558c7473eaf591676b8be5fc8 |