Django, Cannot assign None, does not allow null values

前端 未结 2 638
孤城傲影
孤城傲影 2021-02-14 02:03

i have this models.py

import datetime
from django.db import models
from tinymce import models as tinymce_models
from filebrowser.fields import FileBrowseField

c         


        
相关标签:
2条回答
  • 2021-02-14 02:22
     #for sql 'now()' value use
     published = models.DateField('Published', auto_now_add=True)
     #to allow sql null
     published = models.DateField('Published', null=True, blank=True)
    
    0 讨论(0)
  • 2021-02-14 02:23

    You need to add the parameters "null=True, blank=True" to the definition of published, that way it won't be created as a NOT NULL column in the database:

    published = models.DateField('Published', null=True, blank=True)
    
    0 讨论(0)
提交回复
热议问题