遇到下面的错误,不确定是什么错。在运行python之前,我没有注意到模态中缺少phone字段管理.py迁移。现在,当我尝试运行服务器时,出现以下错误。我确实更改了模式(添加了phone字段),并尝试运行python管理.py迁移。我以为它会重新迁移,但运气不好。得到与下面相同的错误。你知道吗
contacts - models.py:
from django.db import models
from datetime import datetime
# Create your models here.
class Contact(models.Model):
listing = models.CharField(max_length=200)
listing_id = models.IntegerField()
name = models.CharField(max_length=200)
email = models.CharField(max_length=200)
phone = models.CharField(max_length=200)
message = models.TextField(blank=True)
contact_date = models.DateField(default = datetime.now, blank = True)
user_id = models.IntegerField(blank=True)
def __str__(self):
return self.name
contacts - admin.py -
from django.contrib import admin
# Register your models here.
from .models import Contact
class ContactAdmin(admin.ModelAdmin):
list_display =('id', 'name', 'listing', 'email' 'contact_date')
list_diplay_links=('id','name')
search_fields = ('name', 'email', 'listing')
list_per_page=25
admin.site.register(Contact, ContactAdmin)
Error logs:
(venv) User-MBP:btre_project user$ python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapperat 0x110c651e0>
Traceback (most recent call last):
File "/Users/rizwanrenesa/Desktop/btre_project/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/rizwanrenesa/Desktop/btre_project/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/Users/rizwanrenesa/Desktop/btre_project/venv/lib/python3.7/site-packages/django/core/management/base.py", line 425, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
<class 'contacts.admin.ContactAdmin'>: (admin.E108) The value of 'list_display[3]' refers to 'emailcontact_date', which is not a callable, an attribute of 'ContactAdmin', or an attribute or method on 'contacts.Contact'.
在
email
和contact_date
之间缺少逗号:如果字符串文本之间没有运算符,则可以在Python中连接它们,因此这是有效的
这就是错误消息所暗示的。你知道吗
添加逗号,如
你要去参加比赛了。你知道吗
(顺便说一下:
user_id
列应该是user
的ForeignKey,而不是原始ID…)相关问题 更多 >
编程相关推荐