0

我正在使用 django-baton 并且喜欢在内联中给出标签,但无法给出它

这是我的 admin.py 和 model.py 文件的代码

管理员.py

class ContentInLine(admin.StackedInline):
    model = Content
    extra = 1
    
    
    
class schoolProfileAdmin(admin.ModelAdmin):
    # exclude  =  ('content',)
    inlines = [ContentInLine]
    save_on_top = True
    list_display = ('school_name',)

    fieldsets = (
        ('Main', {
            'fields': ('school_name', ),
            'classes': ('baton-tabs-init', 'baton-tab-group-fs-multi--inline-items', 'baton-tab-group-inline-things--fs-another', ),
            'description': 'This is a description text'

        }),

        ('Multiple inlines + fields', {
            'fields': ('email', ),
            'classes': ('tab-fs-multi', ),
        }),
        
    )

模型.py

class SchoolProfile(models.Model):
    id=models.AutoField(primary_key=True)
    user=models.ForeignKey(User,on_delete=models.CASCADE,unique=True)
    school_name = models.CharField(max_length=255)
    school_logo=models.FileField(upload_to='media/', blank=True)
    incharge_name = models.CharField(max_length=255, blank=True)
    email = models.EmailField(max_length=255, blank=True)
    phone_num = models.CharField(max_length=255, blank=True)
    num_of_alu = models.CharField(max_length=255, blank=True)
    num_of_student = models.CharField(max_length=255, blank=True)
    num_of_cal_student = models.CharField(max_length=255, blank=True)
    #content = models.ManyToManyField(Content, blank=True, related_name='groups')

    def __str__(self):
        a = Content.objects.all()
        for e in a:
            print(e.shows_name,'************************')
        return self.school_name

class Content(models.Model):
    id=models.AutoField(primary_key=True)
    user=models.ForeignKey(User,on_delete=models.CASCADE)
    content_type = models.CharField(max_length=255)
    # show=models.CharField(max_length=255)
    show=models.ForeignKey(Show,on_delete=models.CASCADE)
    sponsor_link=models.CharField(max_length=255)
    status=models.BooleanField(default=False)
    added_on=models.DateTimeField(null=True)
    content_file=models.FileField(upload_to='media/')
    title = models.CharField(max_length=255)
    shows_name = models.CharField(max_length=255)
    subtitle = models.CharField(max_length=255)
    description = models.CharField(max_length=500)
    publish_now = models.BooleanField(default=False)
    schedule_release = models.DateField(null=True)
    expiration = models.DateField(null=True)
    tag = models.ManyToManyField(Tag)
    topic = models.ManyToManyField(Topic)
    category = models.ManyToManyField(Category)
    school_profile = models.ForeignKey(SchoolProfile, on_delete=models.CASCADE,unique=True, blank=True)
    
    def __str__(self):
        return self.title 
    

以下是管理页面截图的链接,我无法在内容中获取标签

例如:

内容标题 = 独立标签

内容添加日期和时间 = 另一个选项卡

ETC

django-baton 管理员

4

0 回答 0