当我尝试这个时,我收到了这个错误:
source ./env/bin/activate
sudo python manage.py syncdb
错误:没有名为south的模块
我在激活虚拟环境后安装南部,使用pip install south(以及django)。
在settings.py中安装了应用:
INSTALLED_APPS = (
'south',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
可能是什么问题?
更新: 尝试在没有sudo的情况下同步时出现此错误。也许它与“南方”问题有关:
(env)andrius @ ubuntu:〜/ djcode / myproject $ python manage.py syncdb
Syncing...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/home/andrius/env/local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 90, in handle_noargs
syncdb.Command().execute(**options)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/home/andrius/env/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/home/andrius/env/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/home/andrius/env/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/home/andrius/env/local/lib/python2.7/site-packages/psycopg2-2.4.6-py2.7-linux-x86_64.egg/psycopg2/__init__.py", line 178, in connect
return _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: Peer authentication failed for user "django"
我使用以下命令为数据库创建了数据库和用户:
template1=# create database finance;
CREATE DATABASE
template1=# grant all privileges on database finance to django;
ERROR: role "django" does not exist
template1=# create user django with password 'mydb123';
CREATE ROLE
template1=# grant all privileges on database finance to django;
GRANT
template1=# \q
我在settings.py中的数据库设置:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'finance', # Or path to database file if using sqlite3.
'USER': 'django', # Not used with sqlite3.
'PASSWORD': 'mydb123', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
答案 0 :(得分:8)
在安装南方或运行syncdb时不要成为sudoer。只是做
pip install south python manage.py syncdb
答案 1 :(得分:-1)
从已安装的应用中删除南方
Django 1.7及更高版本不需要南方
要删除南方使用pip卸载,然后y将其完全删除