How to disable inline labels in django inline admin?

Viewed 131

In my Django admin, I want to disable the below-shown paragraph. Please help me out. I am new to changing djano admin. Link to Image

Here is my current admin.py

class ImageInlineAdmin(admin.StackedInline):
    model = Image
    max_num = 1

class BlogAdmin(admin.ModelAdmin):
    inlines = [ParagraphInlineAdmin, ImageInlineAdmin]
    list_display = ['heading','id']

Here are my models

class Container(models.Model):
    heading = models.CharField(max_length=100, blank=True, default="")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def __str__(self) -> str:
        return self.heading

class Paragraph(models.Model):
    content = RichTextUploadingField()
    container = models.ForeignKey(
        Container, on_delete=models.CASCADE, blank=True)

    def __str__(self) -> str:
        return self.content

P.S I am using Django CKeditor

3 Answers

You need to remove the str function from the model that will solve the problem

I removed it via css trick as follow:

class MyClassAdmin(admin.modelAdmin):
    
    inlines = [MyTabularAdmin]

    class Media:
        css = {
            'custom': ('css/custom_admin.css',),
        }

the css is:

.tabular table tbody .original p {
    visibility: hidden;
 }

.inline-group .tabular tr.has_original td {
    padding-top: 10px;
 }

If you don't want to override CSS try this:

Instead of:

def __str__(self) -> str:
        return self.content

Try:

def __str__(self) -> str:
        return ""
Related