creating django model for existing database/sql view?

前端 未结 2 456
挽巷
挽巷 2021-02-04 16:21

I have inserted a definition for a view in $template_dir/sql/$someTableName.sql file. (create or replace view) so every time I run syncdb, the db views are created.

2条回答
  •  暖寄归人
    2021-02-04 17:07

    See Unmanaged models

    You define the model as usual and add managed = False to the meta options:

    class MyModel(models.Model):
        ...
        class Meta:
             managed = False
    

提交回复
热议问题