我有一个类,我在其中声明了20个2个字段的实例。
models.py
class Genre(models.Model):
name = models.CharField(max_length=200,default="Rock")
genre_img = models.ImageField(upload_to="media/",default="1992/08/92")
def __str__(self):
return self.name
class Genrevids(models.Model):
genrename = models.ForeignKey(Genre)
vid_1 = models.CharField(max_length=200,default="Z7JgY9zezj4")
vid_2 = models.CharField(max_length=300,default="Z7JgY9zezd8")
def __str__(self):
return self.vid1
views.py
class ItemInline(admin.TabularInline):
model = Genrevids
extra = 20
class GenreAdmin(admin.ModelAdmin):
fieldsets = [
('The Genre', {'fields': ['genre_name']}),
('Image', {'fields': ['genre_img']}),
]
inlines = [ItemInline]
这样做,它允许我添加20个vid_1
和vid_2
的实例。我想知道是否有办法添加20个vid_1
个实例和10个vid_2
个实例