creating django model for existing database/sql view?

前端 未结 2 446
挽巷
挽巷 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:03

    Try to use python manage.py inspectdb or python manage.py inspectdb > models.py

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题