v1a0 / django-utk

The most useful tools for any django project
GNU General Public License v3.0
3 stars 0 forks source link

DBViewModel #2

Open v1a0 opened 5 months ago

v1a0 commented 5 months ago

Well we need this thing.

I have this kind of vision:

class MyModel(models.DBView):
    some1 = models.SomeField()
    some2 = models.SomeField()

    class Meta:
        db_table = MyModelSQLView.NAME
        view = MyModelSQLView

# sql/sql_view.py

class MyModelSQLView(models.SQLView):
   NAME = "my_sql_view_name"

    V1 = """
       SELECT 
         some1, 
         some2 
       FROM somewhere 
       WHERE some2 > some3;
    """