Django MongoDB在运行tellsiteid时出错 [英] Django MongoDB Engine error when running tellsiteid

查看:135
本文介绍了Django MongoDB在运行tellsiteid时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SO我根据教程创建了一个django项目和应用程序,并且我拥有MongoDB Engine所有必需的依赖项,它似乎都正常工作,直到我尝试启用管理界面。

SO I created a django project and app as per the tutorial and I have all the dependencies necessarry for MongoDB Engine it all seemed to be working fine and dandy till I tried enabling the admin interface.

我取消了需求位的注释,并将django_mongodb_engine和djangotoolbox添加到settings.py

I uncommented the require bits, and added 'django_mongodb_engine' and 'djangotoolbox' to the apps section in settings.py

中的应用程序部分当我尝试获取进入本地主机:8000 / admin我收到一个错误:

When I try to get into localhost:8000/admin I get an error:

AutoField(默认主键)值必须是在MongoDB上代表ObjectId的字符串(取而代之的是u'1)请确保你的SITE_ID包含一个有效的ObjectId字符串。

"AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead). Please make sure your SITE_ID contains a valid ObjectId string."

显然,我必须运行manage.py tellsiteid,它会吐我一个ID我可以在我的settings.py内使用这个错误就会消失,但是当我尝试运行manage.py tellsiteid时,我得到:

After some googling apparently I have to run manage.py tellsiteid and it'll spit me an ID I can use within my settings.py that will make the error go away, but when I try to run manage.py tellsiteid I get:

Traceback (most recent call last):
File "./manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-   packages/django/core/management/__init__.py", line 438, in execute_manager    utility.execute()
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django_mongodb_engine/management/commands/tellsiteid.py", line 8, in handle_noargs
site_id = self._get_site_id()
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django_mongodb_engine/management/commands/tellsiteid.py", line 19, in _get_site_id
return Site.objects.get().id
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django/db/models/manager.py", line 132, in get
return self.get_query_set().get(*args, **kwargs)
File "/Users/holografix/.virtualenvs/django_nonrel_env/lib/python2.7/site-packages/django/db/models/query.py", line 351, in get
% self.model._meta.object_name)
django.contrib.sites.models.DoesNotExist: Site matching query does not exist.


推荐答案

您尚未创建任何网站。运行 manage.py syncdb 创建一个。

You haven't created any Site yet. Run manage.py syncdb to create one.

这篇关于Django MongoDB在运行tellsiteid时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆