DateTimeField doesn't show in admin system

后端 未结 7 1676
野的像风
野的像风 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:08

    It might have to do with the auto_now_add being true. Perhaps instead of that parameter to capture the date on add, you could override the model save method to insert the datetime when the id is null.

    class Rating(models.Model):
    
        ....
        def save(self, *args, **kwargs)
            if not self.id: 
                self.date = datetime.datetime.now()
    

提交回复
热议问题