You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Create materialized view query with .sql file](#create-materialized-view-query-with-sql-file)
29
+
*[Add materialized view query (You can create a materialized view either from Raw SQL or from a queryset)](#add-materialized-view-query-you-can-create-a-materialized-view-either-from-raw-sql-or-from-a-queryset)
30
+
*[Create materialized view from Raw SQL](#create-materialized-view-from-raw-sql)
31
31
*[Create materialized view query from Queryset](#create-materialized-view-query-from-queryset)
32
32
*[Use refresh method to update materialized view data](#use-refresh-method-to-update-materialized-view-data)
33
33
@@ -91,13 +91,15 @@ and proceed to create/delete/update your view on your DB if required.
91
91
to_seconds = models.IntegerField()
92
92
type= models.CharField(max_length=255)
93
93
94
-
defget_query_from_queryset(self):
94
+
# ATTENTION: this method must be a staticmethod or classmethod
95
+
@staticmethod
96
+
defget_query_from_queryset():
95
97
# define this method only in case use queryset as a query for materialized view.
96
98
# Method must return Queryset
97
99
pass
98
100
```
99
-
2. ### Add materialized view query
100
-
-#### Create materialized view query with .sql file
101
+
2. ### Add materialized view query (You can create a materialized view either from Raw SQL or from a queryset)
102
+
-#### Create materialized view from Raw SQL
101
103
1. run django default `makemigrations` command for creating model migrations if necessary:
102
104
```
103
105
./manage.py makemigrations
@@ -124,7 +126,9 @@ and proceed to create/delete/update your view on your DB if required.
124
126
```
125
127
2. add to your materialized view model the method `get_query_from_queryset`:
126
128
```python
127
-
def get_query_from_queryset(self):
129
+
# ATTENTION: this method must be a staticmethod or classmethod
0 commit comments