I saw a question whether I can use the database view as a model in django and try it in my application, but this did not work.
I created the view with the name "vi\_topics"manually and it had a column "id", but I still got the error, even if I added the kernel explicitly "id", saying
"no such column: vi_topics.id"
Here is the definition of my model with the name Vitopic:
from django.db import models
class Vitopic(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
author_name = models.CharField(max_length=200)
author_email = models.CharField(max_length=200)
view_count = models.IntegerField(default=0)
replay_count = models.IntegerField(default=0)
tags = models.CharField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'vi_topics'
Note . I am using sqlite3.
source
share