Reputation: 1944
I am starting with Django development i am following http://www.tangowithdjango.com/ for basic tutorial as i am making some changes into given example i fall into this problem.
Exception Type: OperationalError
Exception Value:
no such column: CodingRat_page.subcategory_id
my models.py is as following.
from django.db import models
# Create your models here.
class Category(models.Model):
name = models.CharField(max_length=128, unique=True)
views = models.IntegerField(default=0)
likes = models.IntegerField(default=0)
def __str__(self):
return self.name
class SubCategory(models.Model):
name = models.CharField(max_length=256, unique=True)
category = models.ForeignKey(Category)
views = models.IntegerField(default=0)
likes = models.IntegerField(default=0)
def __str__(self):
return self.name
class Page(models.Model):
subcategory = models.ForeignKey(SubCategory)
title = models.CharField(max_length=256, default='')
url = models.URLField()
views = models.IntegerField(default=0)
def __str__(self):
return self.title
When i check
sqlall CodingRat
Where i can see subcategory_id. I have run makemigration migration command also still problem exists.I can access other page category and subcategory.
I am using django1.8, pycharm4.5.4 and python3.4.
Thanks in advance.
Upvotes: 0
Views: 1168
Reputation: 1
I didn't had to change the DB name. Just deleted the file. wierd issue though
Upvotes: 0
Reputation: 1944
I have tried most of suggested command on stackoverflow and other forums.
manage.py flush mangae.py makemigrations manage.py migrate manage.py syncdb and few other commands also nothing worked for me.
I deleted the default database and changed the db name in settings.py after this every thing worked like a charm. May be it can help someone.
Upvotes: 1