有没有办法找出这个错误所关注的文件?
serverad@ubuntu:~/django14_project/my_django15_project$ python manage.py runserver --traceback --settings=settings -v 3
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x7fc853a639b0>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 405, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
events.SystemLog.text: (fields.E121) 'max_length' must be a positive integer.
events.SystemLog.type: (fields.E121) 'max_length' must be a positive integer.
System check identified 2 issues (0 silenced).
这是我们上一个程序员留下的系统日志模块
class SystemLog(models.Model):
user = models.ForeignKey(User, related_name='log_actions')
chapter = models.ForeignKey(Chapter, null=True, blank=True, default=None,
related_name="logs")
affected = models.ForeignKey(User, related_name='log_entries', null=True,
blank=True)
type = models.CharField(max_length='20')
text = models.CharField(max_length='100')
date = models.DateTimeField(auto_now_add=True)
read = models.BooleanField(default=False)
is_personal = models.BooleanField(default=False)
答案 0 :(得分:1)
您似乎已在settings.INSTALLED_APPS
中添加了应用events
,它定义了模型SystemLog
。
此模型包含字段text
和字段type
,其定义包含关键字max_length
,其值不是正整数。
如果你使用Eclipse / PyDev,你可以按Ctrl
+ Shift
+ R
并输入SystemLog
来查找该类。
修改强>
鉴于实际模型,max_length
被赋予了字符串而不是整数...
答案 1 :(得分:0)
您可以使用notepad ++或pycharm
进行正则表达式搜索max_length=[^\d]
就你当前的位置而言,你有两个字符串
type = models.CharField(max_length='20')
text = models.CharField(max_length='100')
应该是:
type = models.CharField(max_length=20)
text = models.CharField(max_length=100)