Login

Tag "mongodb"

Snippet List

MongoDB data load

This snippet loads data from JSON files into a MongoDB database. The code is related with the other snippet [MongoDB data dump](http://djangosnippets.org/snippets/2872/). To get it working, just create a ``MONGODB_NAME`` variable in settings, holding the name of your Mongo database. This can be edited to fit more your needs. The snippet requires ``Pymongo``, since it uses its bson module and the ``MongoClient``.

  • loaddata
  • fixtures
  • mongodb
Read More

MongoDB data dump

This Django management command just dumps data from a given MongoDB collection into a JSON file. To get it working, just create a ``MONGODB_NAME`` variable in settings, holding the name of your Mongo database. This can be edited to fit more your needs. The snippet requires Pymongo, since it uses its ``bson`` module and the ``MongoClient``.

  • dump
  • fixtures
  • mongodb
Read More

Tastypie MongoDB Resource

MongoDB Resource for Tastypie ============================= Allows you to create delicious APIs for MongoDB. Settings -------- MONGODB_HOST = None MONGODB_PORT = None MONGODB_DATABASE = "database_name" Example of Usage ---------------- from tastypie import fields from tastypie.authorization import Authorization from tastypie_mongodb.resources import MongoDBResource, Document class DocumentResource(MongoDBResource): id = fields.CharField(attribute="_id") title = fields.CharField(attribute="title", null=True) entities = fields.ListField(attribute="entities", null=True) class Meta: resource_name = "documents" list_allowed_methods = ["delete", "get", "post"] authorization = Authorization() object_class = Document collection = "documents" # collection name Github Repository ================= <https://github.com/fatiherikli/tastypie-mongodb-resource>

  • tastypie
  • mongodb
Read More

3 snippets posted so far.