当我尝试删除User对象时,我得到ProgrammingError
,这就是User.delete发生的地方,它甚至发生在管理员身上。
错误
Django显然认为' auth_user
和apiHandlers_cardholders
之间的关系并不存在于任何地方,数据库没有此列,并且没有models.[y
在名为admin.py
的应用程序中也不是apiHandlers
,但Django期望它,甚至管理站点的一部分专用于它。这只是在我从SQLite迁移到PostGreSQL时才开始发生的。
目前,所有本地依赖项(模型,管理,表单和字段)都在一个名为帮助程序的应用程序中,我不确定这是否有效,但它可以将所有内容保存在一个位置,避免出现并发症。 / p>
更新0.1
没有。其中一个可能会有很多更新
我曾经遇到过与Django Rest Framework相关的迁移问题,但我最终设法通过快速pip install
修复了一个新的restframework更新,它不再给我任何东西了进行迁移和迁移时出错。
以下是我从Django管理员处获得的当前追溯,它在其他删除方法中基本相同。
`
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/auth/user/3/delete/
Django Version: 1.9.2
Python Version: 2.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'oauth2_provider',
'apiHandlers',
'frontEnd',
'helpers',
'nonUser']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware']
Traceback:
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
541. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
244. return view(request, *args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/utils/decorators.py" in inner
184. return func(*args, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/contrib/admin/options.py" in delete_view
1629. [obj], opts, request.user, self.admin_site, using)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/contrib/admin/utils.py" in get_deleted_objects
128. collector.collect(objs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/contrib/admin/utils.py" in collect
193. return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/models/deletion.py" in collect
230. elif sub_objs:
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/models/query.py" in __nonzero__
266. return type(self).__bool__(self)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/models/query.py" in __bool__
262. self._fetch_all()
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
1074. self._result_cache = list(self.iterator())
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/models/query.py" in __iter__
52. results = compiler.execute_sql()
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
848. cursor.execute(sql, params)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/utils.py" in __exit__
95. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/Mason/Documents/dev/FlowFrameWork/flow-framework/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /admin/auth/user/3/delete/
Exception Value: relation "apiHandlers_cardholder" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "apiHandle...
^
`
更新0.2
我正在使用./manage.py runserver
(Mac)来运行它,到目前为止,我还没有设法在我的服务器上使用Nginx和WSGI对其进行测试。
我没有收到警告,说它会影响管理员中的其他模型,例如,我只是立即收到此错误。
答案 0 :(得分:0)
这很可能是因为你在某个地方有一个stray models.pyc文件。清除所有* .pyc文件。如果你在linux上,你可以试试这样的东西:
find . -name '*pyc' -exec 'rm' '{}' ';'
按照./manage.py makemigrations apihandlers
然后./manage.py migrate