Hello, I have the errors in the following: I don't know how can i to do ?
Request Method: GET Request URL: http://articlet/export_excel/ Django Version: 1.6.2 Exception Type: AttributeError Exception Value: 'datetime.time' object has no attribute 'date' Exception Location: /var/www/article/views.py in export_excel, line 195 Python Executable: /usr/bin/python Python Version: 2.6.6 Traceback Switch to copy-and-paste view<http://dev1.so2.co.jp/ihttest/ihttcs_test/export_excel/#> - /usr/lib/python2.6/site-packages/django/core/handlers/base.py in get_response 1. response = wrapped_callback(request, *callback_args, **callback_kwargs) ... ▶ Local vars <http://dev1.so2.co.jp/ihttest/ihttcs_test/export_excel/#> - /var/www/articlee/views.py in export_excel 1. date = att[2].date This is my full views.py: from datetime import datetime, time, date, timedelta class workLog(object): def __init__(self, name, day, attTime, leaveTime): self.name = name self.day = day self.attTime = attTime self.leaveTime = leaveTime def export_excel(request): from staffprofile.models import Myattendance,Myleavework response = HttpResponse(mimetype='application/vnd.ms-excel; charset="Shift_JIS"') response['Content-Disposition'] = 'attachment; filename=file.csv' writer = csv.writer(response) titles = ["No","name""),"day"),"attTime","leaveTime")] writer.writerow(titles) S = Staff.objects.all() row = [workLog('name', i, None, None) for i in range(32)] for att in attendance: day = att[2].day log = logMonth[day] id = att[0] log.name = S.filter(id = id).values("user_name") if log.attTime is None: log.attTime = att[2] elif log.attTime < att[2]: log.attTime = att[2] for leav in leavework: day = leav[2].day log = logMonth[day] if log.leaveTime is None: log.leaveTime = leav[2] elif log.leaveTime < leav[2]: log.leaveTime = leav[2] for log in logMonth: if log.attTime is not None: if log.leaveTime is not None: row.append((log.attTime, log.leaveTime)) else: row.append(None) else: if log.leaveTime is not None: row(None) writer.writerow(row) This is my full models.py class Staff(models.Model): user = models.OneToOneField(User, null=False) user_name = models.CharField(max_length=255) first_kana = models.CharField(max_length=255) last_kana = models.CharField(max_length=255) employee_number = models.CharField(max_length=22) def __unicode__(self): return self.user_name class attendance(models.Model): user = models.ForeignKey(Staff, verbose_name = "name") contact_date = models.DateField(verbose_name = "date", auto_now_add=True) contact_time = models.TimeField(verbose_name = "time", auto_now_add=True) class Meta: ordering = ["-contact_time"] def __unicode__(self): return unicode(self.user) class leavework(models.Model): user = models.ForeignKey(Staff, verbose_name = "name") contact_date = models.DateField(verbose_name = "date", default=datetime.now) contact_time = models.TimeField(verbose_name = "time", default=datetime.now) class Meta: ordering = ["-contact_time"] def __unicode__(self): return unicode(self.user) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dcc033ee-76d7-4870-a495-1c8fb62cb047%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

