当我尝试list_display
在我的 djangoadmin.py
文件中创建一个时,我不断收到以下错误。Truncated incorrect DOUBLE value: 'Penguin Books'
class BookAdmin(admin.ModelAdmin):
list_display = 'title', 'publisher'
admin.site.register(Book, BookAdmin)
class Book(models.Model):
id = models.IntegerField(primary_key=True)
title = models.CharField(max_length=30L)
publisher = models.ForeignKey('Publisher', db_column='publisher')
class Meta:
db_table = 'book'
def __unicode__(self):
return self.name
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/app/books/
Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'books')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "C:\Python27E\lib\site-packages\django\core\handlers\base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python27E\lib\site-packages\django\contrib\admin\options.py" in wrapper
372. return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Python27E\lib\site-packages\django\utils\decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "C:\Python27E\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "C:\Python27E\lib\site-packages\django\contrib\admin\sites.py" in inner
202. return view(request, *args, **kwargs)
File "C:\Python27E\lib\site-packages\django\utils\decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "C:\Python27E\lib\site-packages\django\utils\decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "C:\Python27E\lib\site-packages\django\utils\decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "C:\Python27E\lib\site-packages\django\contrib\admin\options.py" in changelist_view
1285. 'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
File "C:\Python27E\lib\site-packages\django\db\models\query.py" in __len__
90. self._result_cache = list(self.iterator())
File "C:\Python27E\lib\site-packages\django\db\models\query.py" in iterator
301. for row in compiler.results_iter():
File "C:\Python27E\lib\site-packages\django\db\models\sql\compiler.py" in results_iter
775. for rows in self.execute_sql(MULTI):
File "C:\Python27E\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
840. cursor.execute(sql, params)
File "C:\Python27E\lib\site-packages\django\db\backends\util.py" in execute
41. return self.cursor.execute(sql, params)
File "C:\Python27E\lib\site-packages\django\db\backends\mysql\base.py" in execute
120. return self.cursor.execute(query, args)
File "C:\Python27E\lib\site-packages\MySQLdb\cursors.py" in execute
176. if not self._defer_warnings: self._warning_check()
File "C:\Python27E\lib\site-packages\MySQLdb\cursors.py" in _warning_check
92. warn(w[-1], self.Warning, 3)
Exception Type: Warning at /admin/app/books/
Exception Value: Truncated incorrect DOUBLE value: 'Penguin Books'