[django]线上部署后,访问 admin 时出现“DoesNotExist at /admin/ Site matching query does not exist.”错误

将 django 项目部署到服务器后,访问 admin 时出现如下错误:

DoesNotExist at /admin/
Site matching query does not exist.

上网搜索后,参考 http://stackoverflow.com/questions/9736975/django-admin-doesnotexist-at-admin 修复了该问题,下面记录一下解决过程。

两种解决办法:

  • 第一种办法是:编辑 settings.py 文件,从 INSTALLED_APPS 配置项中移除 'django.contrib.sites',

  • 第二种办法:通过 python manage.py shell 为 Site model 添加一条记录(将网站的域名添加进去):

    $ python manage ...
more ...

[django] 创建后台超级用户时出现 TypeError: decode() argument 1 must be string, not None 错误

错误信息如下:

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django ...
more ...