1

I am using django-mongodb engine to connect django with mongodb. I have a model in my application named as bandwidth. when i save data through python manage.py shell , it saves data in a collection named as app_bandwidth. How does this engine saves this data?? Also can I modify the collection name to be per_app_bandwidth.

Nicolas Cortot
  • 6,591
  • 34
  • 44
Dania
  • 1,007
  • 1
  • 14
  • 21

2 Answers2

1

You can change the collection by setting the db_table in the MongoOptions meta class.

See: http://www.django-mongodb.org/reference/model-options.html

Ross
  • 17,861
  • 2
  • 55
  • 73
0

You can do it by adding class Meta to your model Class:

from django.db import models

class AnyDoc(models.Model):
    # some attributes
    name =   models.CharField(max_length=64)
    class Meta:
        db_table='your_collection_name'

    # 

This is working with:
Django <=1.7
django-mongodb-engine 0.6.0
djangotoolbox 1.8.0

There are some examples of earlier versions around using the notation:

class MongoMeta:
    db_table='your_collection_name'
Evhz
  • 8,852
  • 9
  • 51
  • 69