[Tutor] Pymongo Error

James Reynolds eire1130 at gmail.com
Tue Jun 19 09:34:04 EDT 2012


On Tue, Jun 19, 2012 at 1:22 AM, Ranjith Kumar <ranjithtenz at gmail.com>wrote:

> Hi all,
> I tried Django with Mongodb while running manage.py syncdb I endup with
> this error
>
> note : it works fine with sqlite and mysql db
>
> (django-1.3)ranjith at ranjith:~/
> sandbox/python-box/hukkster-core-site/hukk$ ./manage.py syncdb
> /home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/pymongo/connection.py:385:
> UserWarning: must provide a username and password to authenticate to
> hukkster_testing
>   "to authenticate to %s" % (db,))
> Creating tables ...
> Traceback (most recent call last):
>   File "./manage.py", line 14, in <module>
>     execute_manager(settings)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 438, in execute_manager
>     utility.execute()
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 191, in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 220, in execute
>     output = self.handle(*args, **options)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 351, in handle
>     return self.handle_noargs(**options)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py",
> line 109, in handle_noargs
>     emit_post_sync_signal(created_models, verbosity, interactive, db)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/core/management/sql.py",
> line 190, in emit_post_sync_signal
>     interactive=interactive, db=db)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py",
> line 172, in send
>     response = receiver(signal=self, sender=sender, **named)
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
> line 41, in create_permissions
>     "content_type", "codename"
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/db/models/query.py",
> line 107, in _result_iter
>     self._fill_cache()
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/db/models/query.py",
> line 772, in _fill_cache
>     self._result_cache.append(self._iter.next())
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/django/db/models/query.py",
> line 959, in iterator
>     for row in self.query.get_compiler(self.db).results_iter():
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py",
> line 229, in results_iter
>     for entity in self.build_query(fields).fetch(low_mark, high_mark):
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py",
> line 290, in build_query
>     query.order_by(self._get_ordering())
>   File
> "/home/ranjith/virtualenvs/django-1.3/local/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py",
> line 339, in _get_ordering
>     raise DatabaseError("Ordering can't span tables on non-relational
> backends (%s)" % order)
> django.db.utils.DatabaseError: Ordering can't span tables on
> non-relational backends (content_type__app_label)
>
>
> DB settings in settings.py
>
> DATABASES = {
>     'default': {
>     'ENGINE': 'django_mongodb_engine',
>     'NAME': 'helloworld',
>     'USER': '<user123>',
>     'PASSWORD': '12424214',
>     'HOST': 'mongodb://staff.mongohq.com/<db-name>',
>     'PORT': 'XXXXX',
>     },
> }
>
> my requirement packages,
> Django==1.3
> dictshield==0.4.4
> django-mongodb-engine==0.4.0
> django-social-auth==0.6.9
> djangotoolbox==0.0.1
> httplib2==0.7.4
> mongoengine==0.6.10
> mongokit==0.8
> oauth2==1.5.211
> pymongo==2.2
> python-openid==2.2.5
> simplejson==2.5.2
> wsgiref==0.1.2
>
> Please point me what i missed here...
>
> --
> Cheers,
> Ranjith Kumar K,
> Chennai.
>
> http://ranjithtenz.wordpress.com
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


This list here is for new users to python. Using mongo with django is a
pretty advanced topic. I would suggest posting this on stackoverflow, or to
the django-users group (and there are a ton of resources on this already on
those two sites on this topic)

That said, having used mongo with django, I'll bet your problem is that you
are using the django version provided by the django project. For Mongo, you
have to use the django-norel fork. Just google Django Mongo NoRel in
various combinations and you will find it.

To do this, and not screw up your working environment, you will need to
make certain you have a virtual environment set up.

Anyway, once you get it set up, it actually works pretty good.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120619/78a669db/attachment.html>


More information about the Python-list mailing list