Trying to make a blog on Django. For this I use SQLite. I get a one-to-many connection - articles to the comments:
#! /usr/bin/env python # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models # Create your models here. class Article(models.Model): class Meta(): db_table = "article" article_title = models.CharField(max_length=200) article_text = models.TextField() article_date = models.DateTimeField() article_likes = models.IntegerField(default=0) class Comments(models.Model): class Meta(): db_table = 'comments' comments_text = models.TextField() comments_article = models.ForeignKey(Article) There is such an error:
You are trying to add a non-nullable field 'comments_article' to comments without a default; we can't do that (the database needs something to populate existing rows). Where do I need to set a default value? What am I doing wrong ?