我有这样的代码:
模型.py:
from django.db import models
import ioweyou.settings as settings
from comment.models import Comment
class Entry(models.Model):
OPEN = 0
ACCEPTED = 1
REJECTED = 2
DELETED = 3
STATUS_CHOICES = (
(OPEN, 'Open'),
(ACCEPTED, 'Accepted'),
(REJECTED, 'Rejected'),
(DELETED, 'Deleted'),
)
name = models.CharField(max_length=255)
description = models.TextField('entry description', blank=True, null=True)
value = models.DecimalField(max_digits=6, decimal_places=2)
lender = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name='lender')
debtor = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name='debtor')
status = models.SmallIntegerField(default=0, choices=STATUS_CHOICES)
accepted_at = models.DateTimeField(blank=True, null=True)
rejected_at = models.DateTimeField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.name
class EntryComment(Comment):
entry = models.ForeignKey(Entry, null=False, related_name="comments")
管理员.py
class EntryAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['name']}),
('Date information', {'fields': ['accepted_at']}),
]
admin.site.register(models.Entry, EntryAdmin)
和这种错误:
AttributeError at /admin/entry/entry/116/
'unicode' object has no attribute 'date'
Error during template rendering
In template /Library/Python/2.7/site-packages/django/contrib/admin/templates/admin/includes/fieldset.html, error at line 19
django 和 python 最近一直在处理。而我的知识并不完整。有人可以帮助我吗?
当您尝试编辑条目并确定字段接受_at 的值时发生错误(已设置)。