use database view in Django -


I have seen the previous question and try it in my app, but it is not working. I'm manually creating a view called "vi_topics" and had the "id" column in it. But I always get an error about "no such pillar: vi_topics.id", even if I explicitly add the "id" field

Here is my visual model:

django.db import model 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) tag = 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.

Try this:

Managed

the option. Manager

In the new Django 1.1, please see the Release Notes

By default, which means that DJOGO will create appropriate database tables in SyncBB and as part of the reset This is the management command that will remove, Django manages the lifestyle of database tables.

If incorrect, then creating or deleting a database table for this model will not be operated. This is useful if the model represents an existing table or a database view that is created by any other means. This is the only difference when False is managed All other aspects of model handling are generally the same.

  1. Adding an automatic primary key field to the module if you do not declare it, to avoid confusion for later code readers, unmanaged When using models you are recommended to specify all the columns from the database table.
  2. A model = with management = is false, in which a ManyToManyField is another unmanaged model, so many interconnected tables will not be created too many. However, the intermediary table will be created between a managed and an unrestricted model.

    If you need to change this default behavior, then create an intermediate table as a clear model (with a managed set as needed) and use it to relate to using your custom model ManyToManyField.through attribute

For tests involving managed-wrong models, it is to ensure that the correct tables are created.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -