我的django项目有一个工作管理页面,但突然间我收到了:
"Unknown column 'django_content_type.name' in 'field list'"
每当我试图访问管理页时。我仍然可以访问管理员的某些部分,只是不能访问主页。
我对django和python还不太熟悉,所以我不知道去哪里找。
下面是完整的错误:
InternalError at /admin/
(1054, u"Unknown column 'django_content_type.name' in 'field list'")
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.7.7
Exception Type: InternalError
Exception Value:
(1054, u"Unknown column 'django_content_type.name' in 'field list'")
Exception Location: c:\Python27\lib\site-packages\pymysql\err.py in _check_mysql_exception, line 115
Python Executable: c:\Python27\python.exe
Python Version: 2.7.9
Python Path:
['c:\\users\\dhysong\\Documents\\School\\CS6310\\Project4\\CS6310',
'C:\\Windows\\system32\\python27.zip',
'c:\\Python27\\DLLs',
'c:\\Python27\\lib',
'c:\\Python27\\lib\\plat-win',
'c:\\Python27\\lib\\lib-tk',
'c:\\Python27',
'c:\\Python27\\lib\\site-packages']
Server time: Thu, 9 Apr 2015 08:17:05 -0400
第63行出现html错误:
In template c:\Python27\lib\site-packages\django\contrib\admin\templates\admin\index.html, error at line 63
1054
53 <div id="content-related">
54 <div class="module" id="recent-actions-module">
55 <h2>{% trans 'Recent Actions' %}</h2>
56 <h3>{% trans 'My Actions' %}</h3>
57 {% load log %}
58 {% get_admin_log 10 as admin_log for_user user %}
59 {% if not admin_log %}
60 <p>{% trans 'None available' %}</p>
61 {% else %}
62 <ul class="actionlist">
63 {% for entry in admin_log %}
64 <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
65 {% if entry.is_deletion or not entry.get_admin_url %}
66 {{ entry.object_repr }}
67 {% else %}
68 <a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
69 {% endif %}
70 <br/>
71 {% if entry.content_type %}
72 <span class="mini quiet">{% filter capfirst %}{% trans entry.content_type.name %}{% endfilter %}</span>
73 {% else %}
我刚才也遇到过同样的问题,它与django的不同版本有关。我使用pip install-U django将我项目中的所有机器更新为django 1.8,之后一切正常。
这不是django错误,而是MySQL。我刚刚开始了一个项目,但是将django版本从1.8改为1.7,得到了这个错误。所以,我删除了所有表并运行migrate。但你不需要放下所有的桌子,只是一部分,可能只是一张。
在MySQL中,我们的解决方案是 删除表django_content_type
卡蒂克和穆切尔的笔记让我找到了解决办法。 1054安装后发生未知列错误 Django1.8进入一个virtualenv试用,然后尝试 在不同的virtualenv中使用预先存在的Django 1.6。 MySQL搞砸了。
Django 1.7/1.8 syncdb修改了Django_content_type表 正在从中删除“name”列。
因此,删除表,让syncdb根据Django版本的需要重新创建它。 如果你对扔掉它感到紧张,那就去倒吧:
mysqldump -u <mysqladminname> -p <databasename> django_content_type > /tmp/django_content_type.dmp
相关问题 更多 >
编程相关推荐