hide parent category with None

within implementing subcategory scenario, when creating new parent category in insert the parent of the parent with None value inside database, how can i remove this,

concept to achieve :
this code will show result
code

def __str__(self):
        return f"{self.name} - {self.parent}"

result
[First]
result now
[First - None]

Models:

from django.db import models
from mptt.models import MPTTModel, TreeForeignKey


class Category(MPTTModel):
    name = models.CharField(max_length=50, unique=True)
    parent = TreeForeignKey(
        "self",
        null=True,
        blank=True,
        related_name="children",
        db_index=True,
        on_delete=models.CASCADE,
    )

    class MPTTMeta:
        order_insertion_by = ["name"]

    def __str__(self):
        return f"{self.name} - {self.parent}"

The question isn’t clear to me. Can you try elaborating on the situation a little more? Perhaps the code that’s doing the insert and a more detailed description of what you’d like to have happen.

You will need to add the code in your __str__ function to check whether parent is null - and if it is, return the appropriate value.