@@ -15,6 +15,20 @@ without any additional settings.
1515
1616Module also working with [ Grappelli Interface] ( https://github.com/sehmaschine/django-grappelli ) (Optional)
1717
18+ ![ django-streamfield demo screenshot] ( https://raagin.ru/assets/uploads/django-streamfield.png )
19+
20+ ## Contents
21+
22+ - [ Installation] ( #installation )
23+ - [ How to use] ( #how-to-use )
24+ - [ Admin] ( #admin )
25+ - [ Custom Admin for block's models] ( #custom-admin-for-blocks-models )
26+ - [ Override list of blocks for your StreamField in admin.py] ( #override-list-of-blocks-for-your-streamfield-in-adminpy )
27+ - [ Special cases] ( #special-cases )
28+ - [ Complex Blocks] ( #complex-blocks )
29+ - [ Blocks without data in database. Only templates] ( #blocks-without-data-in-database-only-templates )
30+ - [ Cache for reduce the number of database requests] ( #cache-for-reduce-the-number-of-database-requests )
31+ - [ Settings] ( #settings )
1832
1933## Installation
2034` pip install django-streamfield `
@@ -135,7 +149,8 @@ you can get content by field cached property page.stream.render
135149```
136150
137151
138- # # Admin: Custom Admin for block's models
152+ # # Admin
153+ # ## Custom Admin for block's models
139154Models will automaticaly register in admin.
140155If you want provide custom admin class ,
141156first unregister models and register again, using `StreamBlocksAdmin` class .
@@ -164,7 +179,7 @@ As context use "form":
164179{{ form.text.value }}
165180```
166181
167- # # Admin: Set list of blocks for your StreamField in admin site.
182+ # ## Override list of blocks for your StreamField in admin.py
168183Typicaly you set the blocks in your models as `model_list` attribute of StreamField field.
169184But if you want to change blocks, for example depending on object , you can do it in admin site
170185of your model. Suppose you want to use only `RichText` on page with id =1 .
@@ -187,11 +202,12 @@ class PageAdmin(models.Admin):
187202```
188203Be careful with already existing blocks in db. If you remove them from admin, it produce error.
189204
190- # # Complex Blocks
205+ # # Special cases
206+ # ## Complex Blocks
191207You may use StreamField as part of blocks and create with that way complex structure
192208and use `{{ block_content.< field_name> .render }}`
193209
194- # # Blocks without data in database. Only templates.
210+ # ## Blocks without data in database. Only templates.
195211You may use it for widgets or separators or for whatever you want...
196212Just make the block model `abstract` .
197213```python
@@ -203,7 +219,7 @@ class EmptyBlock(models.Model):
203219and use `streamblocks/ templates/ streamblocks/ emptyblock.html` for your content.
204220> Note: Don' t forget to register a block in STREAMBLOCKS_MODELS
205221
206- # # Cache for reduce the number of database requests
222+ # ## Cache for reduce the number of database requests
207223There is two ways of caching:
208224- Simple cache view with django cache
209225- Create additional field, for example: ' stream_rendered'
@@ -220,14 +236,14 @@ def save(self, *args, **kwargs):
220236```python
221237# settings.py
222238```
223- ** STREAMFIELD_STREAMBLOCKS_APP_PATH **
239+ # ## STREAMFIELD_STREAMBLOCKS_APP_PATH
224240
225241If your app `streamblocks` located not in project root directory, you need to reflect it in settings.py
226242```python
227243STREAMFIELD_STREAMBLOCKS_APP_PATH = ' yourapps.streamblocks'
228244```
229245
230- ** STREAMFIELD_BLOCK_OPTIONS **
246+ # ## STREAMFIELD_BLOCK_OPTIONS
231247
232248You may use `STREAMFIELD_BLOCK_OPTIONS ` in settings.py to add some options to block.
233249
0 commit comments