如何使 model.ImageField 在 django admin 中成为强制性的?
How to make model.ImageField as mandatory in django admin?
我需要在 django 管理面板中将上传图片作为必填字段,有没有可能?
这是我所做的:
models.py
class ContentData(models.Model):
title = models.CharField(max_length=100,null = True)
description = models.TextField(null=True)
image = models.ImageField(upload_to="uploads", blank=True)
is_active = models.IntegerField(default = 1,
blank = True,
null = True,
help_text ='1->Active, 0->Inactive',
choices =(
(1, 'Active'), (0, 'Inactive')
))
created_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
我刚删除
blank=True
在图像字段中。
我需要在 django 管理面板中将上传图片作为必填字段,有没有可能?
这是我所做的:
models.py
class ContentData(models.Model):
title = models.CharField(max_length=100,null = True)
description = models.TextField(null=True)
image = models.ImageField(upload_to="uploads", blank=True)
is_active = models.IntegerField(default = 1,
blank = True,
null = True,
help_text ='1->Active, 0->Inactive',
choices =(
(1, 'Active'), (0, 'Inactive')
))
created_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
我刚删除
blank=True
在图像字段中。