mardi 5 mai 2015

AttributeError in Django admin 'datetime.date' object has no attribute 'date'

Django 1.6, PostgreSQL, time zone support disabled.

After adding new instance of GetData in standard Django admin and save it, when i want to edit this instance i have error:

AttributeError at /admin/app/getdata/2/
'datetime.date' object has no attribute 'date'

I made two models:

class GetData(models.Model):
   cookie = models.CharField(null=True, blank=True, max_length=255)
   mail = models.EmailField(null=True, blank=True, max_length=75)
   first_visit = models.DateTimeField(null=True, blank=True)
   last_visit = models.DateTimeField(null=True, blank=True)

   def __unicode__(self):
      return self.cookie

class GetUrl(models.Model):
    cookie = models.ForeignKey('GetData')
    url = models.CharField(null=True, blank=True, max_length=255)

my admin.py looks like this:

from django.contrib import admin
from app.models import GetData, GetUrl

class GetDataAdmin(admin.ModelAdmin):
    pass
admin.site.register(GetData, GetDataAdmin)

class GetUrlAdmin(admin.ModelAdmin):
    pass
admin.site.register(GetUrl, GetUrlAdmin)

And i adding simple data to Django admin: enter image description here

Aucun commentaire:

Enregistrer un commentaire