Reputation: 3
I am a beginner in Django and up to now I was amazed how simple it was. I am running django 3 with an sqlite3 DB. I want to remove an attribute of one of my models. In this particular case it's "slug".
models.py
class Recipe(models.Model):
title = models.CharField(max_length=100)
creator = models.CharField(max_length=42)
content = models.TextField(null=True)
creation_date = models.DateTimeField(default=timezone.now,
verbose_name="Creation date")
photo = models.ImageField(upload_to="photos/")
main_ingredient = models.ManyToManyField('Ingredient', related_name='recipes')
slug = models.SlugField(max_length=100)
class Meta:
verbose_name = "recipe"
ordering = ['creation_date']
def __str__(self):
return self.title
I just delete the line and ran
python manage.py makemigration
I got the following error
SystemCheckError: System check identified some issues:
ERRORS:
<class 'recipes.admin.RecipeAdmin'>: (admin.E027) The value of 'prepopulated_fields' refers to 'slug', which is not an attribute of 'recipes.Recipe'.
I suppose django does not want to delete the line from the DB. I have to do it manually then I tried this
But it does not work for sqlite as explained here
So far I was amazed by Django and this is a major drawback. Is there an easier way? what am I doing wrong?
Thank you for your help
Upvotes: 0
Views: 80
Reputation: 6616
Take a look in your admin.py
file, you left a reference to it in there.
The error points to the problem. You deleted the slug field but left it in the prepopulated_fields
of RecipeAdmin
.
Upvotes: 1