N
N
Nubbin2018-10-18 16:57:26
Django
Nubbin, 2018-10-18 16:57:26

How to remove an empty list item?

Good evening here is the model

class ItemStatus(models.Model):
    name = models.CharField(max_length=200)

    def __str__(self):
        return self.name

class Item(models.Model):
    name = models.CharField(max_length=200, unique=True)
    status = models.ForeignKey(ItemStatus, default=None, null=True, blank=True, on_delete=models.CASCADE)

5bc8910726e9b006597575.png
How can I remove "----" from the list so I can make sure to select an item from the list.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-10-18
@Nubbin

Make the field statusmandatory at the model level, that is, remove it null=Trueandblank=True

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question