私はこの種のコードを持っています:
models.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")
admin.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 は最近扱っています。そして、私の知識は完全ではありません。誰でも私を助けることができますか?
Entry を編集しようとして、フィールド Accepted_at の値が決定されている (設定済み) 場合にエラーが発生します。