I am trying to use MongoDB with Django. I followed this guide to set it up so that all the necessary things are installed.
MongoDB + Django Tutorial
My problem is this: When I try to run cities = City.objects.get()in mine, views.pyI get the following error:
DoesNotExist at /GetAllCities/
City matching query does not exist.
My MongoDB looks like this
Databasename = "exjobb"
Collectioname = "cities"`
And it contains 30,000 rows of data, it works with my Rails and PHP application.
My model class is as follows
from django.db import models
from django.core.urlresolvers import reverse
from djangotoolbox.fields import ListField, EmbeddedModelField
class City(models.Model):
city = models.TextField()
loc = models.TextField()
population = models.IntegerField()
state = models.TextField()
_id = models.IntegerField()
def __unicode__(self):
return self.city
And one row in the database looks like
{
"city" : "ACMAR",
"loc" : [
-86.51557,
33.584132
],
"population" : 6055,
"state" : "AL",
"_id" : "35004"
}
source
share