I am making a simple application in Django, where I want my admins to be able to go into the admin panel and create a Level object
class Level(models.Model):
content = models.CharField(max_length = 200)
^^ This is my simple layout for the model, only admins can create this.
However, when my admins create the Level object, it shows up like this:
How it shows up in admin panel
I don't want this, and I want that to be replaced with the string content, which is a field in my Level model
So instead of looking like above, I want it to just contain the context.
How can I do this?
CodePudding user response:
You just need to change the string to be the content:
class Level(models.Model):
content = models.CharField(max_length = 200)
def __str__(self):
return f"{self.content}"
CodePudding user response:
class Level(models.Model):
content = models.CharField(max_length = 200)
def __str__(self):
return self.content