DateTimeField doesn't show in admin system

后端 未结 7 1669
野的像风
野的像风 2020-12-05 01:27

How come my \"date\" field doesn\'t come up in the admin system?

In my admin.py file i have

from django.contrib import admin
from glasses.players.mod         


        
相关标签:
7条回答
  • 2020-12-05 02:27

    Major Hack:

    If you really need to do this (as I do) you can always hack around it by immediatley setting the field to be "editable" defining the field as follows:

    class Point(models.Model):
      mystamp=models.DateTimeField("When Created",auto_now_add=True)
      mystamp.editable=True
    

    This will make the field editable, so you can actually alter it. It seems to work fine, at least with the mysql backing engine. I cannot say for certian if other backing stores would make this data immutable in the database and thus cause a problem when editing is attempted, so use with caution.

    0 讨论(0)
提交回复
热议问题