0

I have an app called "web". In models.py I write Income model:

models.py

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Income(models.Model):
    text = models.CharField(max_length=255)
    date = models.DateTimeField()
    amount = models.BigIntegerField()
    user = models.ForeignKey(User, on_delete=models.CASCADE)

but I see this: Income object(1), however I want to see wage!

image of problem

karel
  • 5,489
  • 46
  • 45
  • 50

1 Answers1

0

Add __str__ function to your model

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Income(models.Model):
    text = models.CharField(max_length=255)
    date = models.DateTimeField()
    amount = models.BigIntegerField()
    user = models.ForeignKey(User, on_delete=models.CASCADE)    

    def __str__(self):
        self.amount`
webbyfox
  • 1,049
  • 10
  • 22