[Django]-Django only adding one field from model

4πŸ‘

βœ…

I’m pretty sure the issue is caused by the commas you have for the trailing fields, in python, this is indicating that you’re creating a tuple and it will treat the next line as a continuation of that tuple object, you need to remove them

class Testimonial(models.Model):
    name = models.CharField(max_length=20, null=True),
    quote = models.CharField(max_length=255, null=True),
    test = models.CharField(max_length=20, null=True)

should be

class Testimonial(models.Model):
    name = models.CharField(max_length=20, null=True)
    quote = models.CharField(max_length=255, null=True)
    test = models.CharField(max_length=20, null=True)
πŸ‘€Sayse

0πŸ‘

If you do not want to remove the β€œquote” – simply remove manually the operation of this migration.

operations = [
    migrations.AddField(
        model_name='testimonial',
        name='test',
        field=models.CharField(max_length=20, null=True),
    ),
]

And execute: python manage.py migrate app_name. Perhaps when you create a migration, you accidentally commented out this field.

Leave a comment