如何修复 django_sites 表? [英] How to fix the django_sites table?

查看:15
本文介绍了如何修复 django_sites 表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图让 oauth 模块工作,我采取了以下措施:manage.py 重置站点

Trying to get an oauth module to work I made the pro-move of : manage.py reset sites

这会导致我网站的管理员和登录功能失效.

This had the effect killing the admin and login functionality of my site.

所以,我的问题是如何回到原点并修复我破坏的问题.

So, my question is how to I get back to square one and fix what I broke.

这是我当前尝试显示管理工具时的错误:

Here is my current error when trying to display the admin tool:

DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL:    http://mdev.5buckchuck.com/admin/
Django Version: 1.3
Exception Type: DoesNotExist
Exception Value:    
Site matching query does not exist.`

我查看了文档,但我对此感到迷茫和厌倦:http://docs.djangoproject.com/en/1.3/ref/contrib/网站/

I looked at the documentation but I am lost and tired in it: http://docs.djangoproject.com/en/1.3/ref/contrib/sites/

好像在提示:manage.py syncdb

所以,我想知道下一步该做什么......

So, I wonder what to do next...

推荐答案

如果您只从项目中运行一个站点,您实际上并不需要 sites 框架,因此最简单的解决方法是从您的 INSTALLED_APPS 中删除以下项目,错误应该会消失:

You don't really need the sites framework if you only run one site from the project, so the easiest fix would be to remove the following item from your INSTALLED_APPS and the error should go away:

'django.contrib.sites'

您还可以从 shell 重新创建丢失的 Site 对象.运行 python manage.py shell 然后:

You can also re-create the missing Site object from shell. Run python manage.py shell and then:

from django.contrib.sites.models import Site
Site.objects.create(pk=1, domain='mdev.5buckchuck.com', name='5buckchuck.com')

这篇关于如何修复 django_sites 表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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