Skip to content

Commit df52fe1

Browse files
committed
fix README.md
1 parent 0929bc5 commit df52fe1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ in order to change query of parent materialized view.
2626
* [Installation](#installation)
2727
* [Usage](#Usage)
2828
* [Create class and inherit from MaterializedViewModel](#create-class-and-inherit-from-materializedviewmodel)
29-
* [Add materialized view query](#add-materialized-view-query)
30-
* [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)
3131
* [Create materialized view query from Queryset](#create-materialized-view-query-from-queryset)
3232
* [Use refresh method to update materialized view data](#use-refresh-method-to-update-materialized-view-data)
3333

@@ -91,13 +91,15 @@ and proceed to create/delete/update your view on your DB if required.
9191
to_seconds = models.IntegerField()
9292
type = models.CharField(max_length=255)
9393

94-
def get_query_from_queryset(self):
94+
# ATTENTION: this method must be a staticmethod or classmethod
95+
@staticmethod
96+
def get_query_from_queryset():
9597
# define this method only in case use queryset as a query for materialized view.
9698
# Method must return Queryset
9799
pass
98100
```
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
101103
1. run django default `makemigrations` command for creating model migrations if necessary:
102104
```
103105
./manage.py makemigrations
@@ -124,7 +126,9 @@ and proceed to create/delete/update your view on your DB if required.
124126
```
125127
2. add to your materialized view model the method `get_query_from_queryset`:
126128
```python
127-
def get_query_from_queryset(self):
129+
# ATTENTION: this method must be a staticmethod or classmethod
130+
@staticmethod
131+
def get_query_from_queryset():
128132
return SomeModel.objects.all()
129133
```
130134
3. run django command `migrate_with_views`:

0 commit comments

Comments
 (0)