0

For any django experts

I have created a blog app in the root-directory of my project and created a Post model in the models file of the blog app. I made the migrations to the database just fine, but later I realised I needed to add another field in the Post model-- an author field which is a ForeignKey linked to a User, but when I try to make the migrations it keeps telling me "django.db.utils.OperationalError:no such column: blog_post.author_id" this is in the python shell, when I am trying to create a new post. I already had other posts created before I added the author field. If it can help, here is my model class Post(models.Model): title=models.CharField(max_length=30) slug = models.SlugField(max_length=20) body = models.TextField() author = models.ForeignKey(User,on_delete=models.CASCADE,related_name='blog_post') published = models.DateTimeField(auto_now_add=True) .... Any help will be appreciated.

6th May 2020, 2:32 PM
prime omondi
prime omondi - avatar
2 Respuestas
+ 1
Did you makemigrations?
7th May 2020, 5:19 AM
R Vijay Anand
R Vijay Anand - avatar
0
Yes I did after updating the author field and it gives me this error message "django.db.utils.OperationalError: table blog_post has no column named author_id"
7th May 2020, 7:40 AM
prime omondi
prime omondi - avatar