Reputation: 169
I'm building a blog with django and I tried to add new field to models.And also I makemigrations and migrate to database.And also I tried many other things like these stackoverflow,stackoverflow question 2 But I finally got a operational error at / no such column:
from django.db import models
from django.contrib.auth.models import User
from ckeditor.fields import RichTextField
STATUS = (
(0,"Draft"),
(1,"Publish")
)
class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete=
models.CASCADE,related_name='blog_posts')
updated_on = models.DateTimeField(auto_now= True)
content = RichTextField(blank=True, null=True)
created_on = models.DateTimeField(auto_now_add=True)
status = models.IntegerField(choices=STATUS, default=0)
image = models.ImageField(upload_to='images',null=True, blank=True)
class Meta:
ordering = ['-created_on']
def __str__(self):
return self.title
Upvotes: 0
Views: 159
Reputation: 82
I know a way to fix this error frst you have to delete the database and just run this commands python manage.py makemigrations
after that python manage.py migrate --run-syncdb
run this command.Hope it works.
Upvotes: 1