我在我的抽象模型中创建 created_by 和 modified_by 字段。Django 版本:1.4.3
Python 版本:2.7.3
根据文档我创建了我的抽象类:
# base.py
class MyModel(models.Model):
created_by = models.ForeignKey('userdata.Profile',
related_name=
'%(app_label)s_%(class)s_created_by',
default=1)
modified_by = models.ForeignKey('userdata.Profile',
related_name=
'%(app_label)s_%(class)s_modified_by',
default=1)
class Meta:
abstract = True
我在我的所有模型中都继承了这个模型,大约有 50 个模型。
syncdb - 好的
南 - 好的
runserver - 好的
我通过 SQLite Manager 查看我的表格,一切看起来都很好。
我登录到管理站点并打开我的任何表,我得到:
Traceback:
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\contrib\admin\options.py" in wrapper
366. return self.admin_site.admin_view(view)(*args, **kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\utils\decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\views\decorators\cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\contrib\admin\sites.py" in inner
196. return view(request, *args, **kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\utils\decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\utils\decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\utils\decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\contrib\admin\options.py" in changelist_view
1233. 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\db\models\query.py" in __len__
85. self._result_cache = list(self.iterator())
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\db\models\query.py" in iterator
291. for row in compiler.results_iter():
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\db\models\sql\compiler.py" in results_iter
763. for rows in self.execute_sql(MULTI):
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\db\models\sql\compiler.py" in execute_sql
818. cursor.execute(sql, params)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\db\backends\util.py" in execute
40. return self.cursor.execute(sql, params)
File "I:\xxx\virtualenvs\fff-2\lib\site-packages\django-1.4.3-py2.7.egg\django\db\backends\sqlite3\base.py" in execute
344. return Database.Cursor.execute(self, query, params)
Exception Type: DatabaseError at /admin/userdata/address/
Exception Value: at most 64 tables in a join
我的问题是:你能看出这个例子有什么错误吗?
我的问题 2:SQLite 是否限制为 64 个连接?在 Postgres 上会好吗?
编辑:
是的,当我在管理面板中打开任何模型的列表视图时,就会发生这种情况。
我从所有 list_displays 中删除了 created_by 和 modified_by。在使用 SQLite 的本地机器上和使用 Postgres 的服务器上都没有帮助
所有测试都是正确的。