views:

255

answers:

1

I saw the former question can i use a database view as a model in django and try it in my app,but that's not work.I create a view named "vi_topics" manually and it had "id" column。But I always got the error about "no such column: vi_topics.id",even I add "id" field explicitly.

here is my view models :

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'

btw: I use sqlite3.

A: 

id = models.IntegerField(primary_key=True)

Acti67