I saw many tutorials on how to create a File upload field / Image Field using forms and templates. But I have a model called TestModel and I want to manage it with Django's default admin panel, how can I add a upload field to it ?
class TestModel(models.Model):
cover = models.ImageField(upload_to='covers')
when I try makemigrations
, result will be :
You are trying to add a non-nullable field 'cover' to testmodel without a default; we can't do that ( the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows) 2) Quit, and let me add a default in models.py Select an option:
What it the problem ?