新鲜的数据库和Django manage.py shell和syncdb没有运行

时间:2015-05-25 10:20:11

标签: python django postgresql shell

我的Django项目运行良好,我想删除我的数据库并创建一个新的数据库以测试我的代码中的一些功能。创建一个新的Postgre后 SQL DB。我运行./manage.py syncdb和shell,我也尝试了其他命令,如flush,但结果与下面相同

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/management/commands/shell.py", line 70, in handle_noargs
    get_models()
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/loading.py", line 232, in get_models
    self._populate()
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate
    self.load_app(app_name, True)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/ashok/env/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 9, in <module>
    dt_settings.patch_all()
  File "/home/ashok/env/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 232, in patch_all
    patch_root_urlconf()
  File "/home/ashok/env/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 220, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 480, in reverse
    app_list = resolver.app_dict[ns]
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 310, in app_dict
    self._populate()
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 262, in _populate
    for pattern in reversed(self.url_patterns):
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 346, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 341, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/ashok/newproject/pflat/jntu/urls.py", line 11, in <module>
    url(r'^base/', include('base.urls')),
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 26, in include
    urlconf_module = import_module(urlconf_module)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/ashok/newproject/pflat/base/urls.py", line 3, in <module>
    from base import views
  File "/home/ashok/newproject/pflat/base/views.py", line 35, in <module>
    @cr('Base/CSV Import')
  File "/home/ashok/newproject/pflat/role/role_contrib.py", line 56, in cr_dec
    role = gr(role_name)
  File "/home/ashok/newproject/pflat/role/role_contrib.py", line 28, in gr
    return Role.objects.filter(name = role_name)[0]
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 132, in __getitem__
    return list(qs)[0]
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 96, in __iter__
    self._fetch_all()
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 854, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 710, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 781, in execute_sql
    cursor.execute(sql, params)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/backends/util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/ashok/env/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "role_role" does not exist
LINE 1: ...role_role"."description", "role_role"."date" FROM "role_role...

Djano版本:1.6.2

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base',
'registration',
'course',
'south',
'chosen',
'accounts',
'prephd',
'role',
'resmet',
'messages',
'materializecssform',
'debug_toolbar',

2 个答案:

答案 0 :(得分:1)

django.db.utils.ProgrammingError: relation "role_role" does not exist

在settings.py中检查INSTALLED_APPS,您缺少一个应用程序

答案 1 :(得分:0)

很抱歉没有提供INSTALLED_APPS的信息。

我从INSTALLED_APPS

中删除了debug_toolbar后解决了我的问题