0

I have a ModelForm with the following field definition:

updated_at = models.DateTimeField("Last-Modified", auto_now=True)

And when I do this in my form:

class Meta:
    model = Page
    fields = ('title', 'views', 'updated_at')

I get: Unknown field(s) (updated_at) specified for Page exception.

If I remove auto_now=True it works but I don't want to do that. I just want to display updated_at in my template, it will not be manually editable.

halfer
  • 19,824
  • 17
  • 99
  • 186
Adam
  • 2,948
  • 10
  • 43
  • 74
  • See http://stackoverflow.com/questions/10033422/cant-display-datefield-on-form-with-auto-now-true and http://stackoverflow.com/questions/1737017/django-auto-now-and-auto-now-add. – alecxe Mar 10 '14 at 15:33
  • possible duplicate of [DateTimeField doesn't show in admin system](http://stackoverflow.com/questions/6386172/datetimefield-doesnt-show-in-admin-system), http://stackoverflow.com/questions/1737017/django-auto-now-and-auto-now-add, http://stackoverflow.com/questions/10033422/cant-display-datefield-on-form-with-auto-now-true – dani herrera Mar 10 '14 at 15:35

1 Answers1

0

add editable param to the define field:

updated_ad = models.DateTimeField('Last Modefied', auto_now=True, editable=True)
freylis
  • 814
  • 6
  • 15