如何在我的表中禁用None,表AUTORDOCUMENT只有外键。
我试过admin.py:
from django.contrib.admin.views import main
class MyModelAdmin(admin.ModelAdmin):
def __init__(self,*args,**kwargs):
super(MyModelAdmin, self).__init__(*args, **kwargs)
main.EMPTY_CHANGELIST_VALUE = ''
但我仍然没有
models.py
class AutorDocument(models.Model):
idAuthor=models.ForeignKey(Author,on_delete=models.CASCADE,null=True,verbose_name ='Author')
document=models.ForeignKey(Document,on_delete=models.CASCADE,null=True,verbose_name='title')
def __str__(self):
return unicode(self.idAutor)+' Titulo tesis: '+ unicode(self.tesis)
def __unicode__(self):
return smart_unicode(('%s %s' % (self.idAutor,self.tesis) ))
class Author(models.Model):
Firtname=models.CharField(max_length=50)
middlename=models.CharField(max_length=50,null=True, blank=True)
secondsurname=models.CharField(max_length=30)
lastName=models.CharField(max_length=30)
def __str__(self):
return unicode(self.lastName)+' '+
unicode(self.secondsurname)+' '+unicode(self.Firtname)
def __unicode__(self):
return smart_unicode(('%s %s %s %s' %
(self.Firtname,self.middlename,self.secondsurname,self.lastName) ))
class Document(models.Model):
title=models.CharField(max_length=200,primary_key=True)
def __str__(self):
return self.titulo
def __unicode__(self):
return smart_unicode(('%s' % (self.titulo) ))
作者和文档是AuthorDocument
引用的模型答案 0 :(得分:0)
[ "Text...", "Other text...", "ok", "ok Another text..." ]