Search code examples
pythondjangodjango-modelsimagefield

Django imageField


I'm trying to set an imageField for upload an image on the admin page, but this error raises.

no such column: series_serie.serie_cover

This is the model:

class Serie (models.Model):
    serie_name = models.CharField(max_length=100)
    serie_cover = models.ImageField(upload_to='/')

    def __str__(self):
        return (self.serie_name)

This is migration file:

        migrations.CreateModel(
        name='Serie',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('serie_name', models.CharField(max_length=100)),
            ('serie_cover', models.ImageField(upload_to=b'')),
        ],

I've made the following:

  1. python manage.py flush
  2. python manage.py makemigrations
  3. python manage.py migrate

Then I try to access the Serie model from admin side but got that error.

What I could do?

Thanks.


Solution

  • I solved it removing the file 'db.sqlite3' and re generating it with makemigrations. For some reason the name was stuck there and I couldn't change it.