For some reason, the default value for a Django model field I have doesn't work. As in, if the value is left blank by the user when creating an object for that model, then when the value is used in a template, it shows on the website as blank as opposed to the default value. Why is this?


(the category field)

class Auction(models.Model):
    username = models.CharField(max_length=50)
    title = models.CharField(max_length=64)
    price = models.CharField(max_length=64)
    description = models.CharField(max_length=100)
    creation_date = models.DateTimeField()
    photo = models.FileField(null=True, blank=True)
    category = models.CharField(max_length=64, default="No category listed")
    active = models.BooleanField(default=True)
    winner = models.CharField(max_length=50, blank=True)

(This is for project 2 - commerce)

Thank you!

1 Answer 1


Inside models.py I have...

class = AuctionListing(models.Model):
    ('None', 'None')

category = models.CharField(max_length=4, choices = CATEGORY_CHOICES, default = 'None')

and inside the admin view I can see the category section as 'None'. Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .