如何解决django独一无二,即使
即使post_type是索引1,我也想一起使用unique。 对于每个部分,只能一次选择文章类型索引1,但可以不受限制地选择索引0。
class Post(models.Model):
Article_type = (('news','Het laatste nieuws'),('introduction','Een introductie'))
post_id = models.AutoField(primary_key=True)
post_title = models.CharField(max_length=50,null=False)
post_header = models.TextField(max_length=250,null=True,blank=True)
post_body = RichTextUploadingField(null=True)
post_expire_date = models.DateTimeField(null=True,blank=True)
post_available_date = models.DateTimeField(default=timezone.now,null=False)
post_image = models.ImageField(upload_to='post-uploads/',blank=True)
post_section = models.ForeignKey(Section,on_delete=models.CASCADE,default=1)
post_type = models.CharField(max_length=30,choices=Article_type,default="news")
post_author = models.ForeignKey(
user,limit_choices_to={'is_staff': True},default=user,)
slug = models.SlugField(unique=True)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。