I wanted to add a slug field to my model Profile (that extends the User model) after I had several profiles created, then an error appeared when reaching the profile page with the slug in the url saying :
Django OperationalError: no such column: infrastructure_profile.slug
so I looked here and saw this answer
and it suggested I delete all my migrations files to restart the database , so I did
and then I got the same error , so I thought I should delete all the users I already have that didn't had the slug field already including the superuser.
so I followed this answer
and I got that error
django.db.utils.OperationalError: no such column: infrastructure_profile.slug
any idea what's going on ?
Edit
My models.py contains the model Profile like so
class Profile(User):
user = models.OneToOneField(User, parent_link=True, on_delete=models.CASCADE)
bio = models.TextField()
slug = models.SlugField(unique=True, blank=True)
avatar_thumbnail = ProcessedImageField(upload_to='images/',
default='/images/default.png',
processors=[ResizeToFill(300, 300)],
format='JPEG',
options={'quality': 60})
location = models.TextField()
tags = models.ManyToManyField(Tag)
contact_information = models.TextField()
verified = models.BooleanField(default=False)
counter = models.IntegerField(default=0)
def __str__(self):
return self.user.username
def save(self, *args, **kwargs):
print('self.username')
print(self.user.username)
self.slug = self.user.username
super(Profile, self).save(*args, **kwargs)
def get_absolute_url(self):
return reverse('infrastructure:edit-user-profile', kwargs={'slug': self.slug})