2
我試圖在管理中添加一個「事件」,並得到這個錯誤:類型錯誤,「Class對象」對象不標化
TypeError at /admin/sms/event/add/ 'Contact' object is not subscriptable
models.py:
class Contact(models.Model):
users = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name="contact")
name = models.CharField(_("Recipient"), max_length=40)
phone = models.IntegerField(_("Phone"), max_length=10)
def __unicode__(self):
return "%s: %d" % (self.name, self.phone)
class Event(models.Model):
calendar = models.ForeignKey(Calendar, verbose_name=_("Calendar"), related_name="event_calendar")
message = models.ForeignKey(Message, verbose_name=_("Message"), related_name="event_message")
recipient = models.ForeignKey(Contact, verbose_name=_("Recipient"), related_name="event1")
event_date = models.DateField(_("Date"))
start_time = models.TimeField(_("Start time"))
end_time = models.TimeField(_("End time"), blank=True, null=True)
location = models.CharField(_("Location of meeting"), blank=True, null=True, max_length=100)
reminder_options = models.IntegerField(choices=ReminderOptions.CHOICES, verbose_name=_("Reminder time"))
content = models.CharField(_("Event Notes"), max_length=160)
# recurring_options = models.IntegerField(choices=RecurringOptions.CHOICES, verbose_name=_("Recurring time"))
def __unicode__(self):
return self.recipient
def get_absolute_url(self):
return u'/create-event/'
它將它添加到數據庫,然後拋出錯誤? – karthikr 2013-05-07 16:15:06
你有定製的管理模式嗎?如果是這樣,請發佈我們的admin.py – Aldarund 2013-05-07 16:36:23