Skip to content

Commit 65eeb0d

Browse files
committed
v1.1.2
1 parent d22ac2b commit 65eeb0d

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ Module also working with [Grappelli Interface](https://github.com/sehmaschine/dj
2929
- [Special cases](#special-cases)
3030
- [Complex Blocks](#complex-blocks)
3131
- [Blocks without data in database. Only templates](#blocks-without-data-in-database-only-templates)
32+
- [Add extra context to blocks](#add-extra-context-to-blocks)
3233
- [Cache for reduce the number of database requests](#cache-for-reduce-the-number-of-database-requests)
3334
- [Settings](#settings)
3435

3536
## Installation
37+
38+
Requirements: `django>=3.*`
39+
3640
`pip install django-streamfield`
3741

3842
## How to use
@@ -150,6 +154,16 @@ you can get content by field cached property page.stream.render
150154
...
151155
```
152156

157+
Or, if you need extra context in blocks, you may use template tag:
158+
```html
159+
{% load streamfield_tags %}
160+
...
161+
<div class="content">
162+
{% stream_render page.stream request=request %}
163+
</div>
164+
...
165+
```
166+
153167

154168
## Admin
155169
### Custom admin class for block's models
@@ -268,6 +282,21 @@ class EmptyBlock(models.Model):
268282
and use `streamblocks/templates/streamblocks/emptyblock.html` for your content.
269283
> Note: Don't forget to register a block in STREAMBLOCKS_MODELS
270284

285+
### Add extra context to blocks
286+
Supose, you need to add some data to blocks from global context.
287+
Instead of using render property in template `{{ page.stream.render }}`,
288+
you need to use template tag `stream_render` from `streamfield_tags` with keywords arguments.
289+
290+
For example, if you have in page template `request` and `page` objects and want to use it in blocks:
291+
```html
292+
{% load streamfield_tags %}
293+
...
294+
<div class="content">
295+
{% stream_render page.stream request=request page=page %}
296+
</div>
297+
...
298+
```
299+
271300
### Cache for reduce the number of database requests
272301
There is two ways of caching:
273302
- Simple cache view with django cache

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="django-streamfield",
8-
version="1.1.1",
8+
version="1.1.2",
99
author="Yury Lapshinov",
1010
author_email="y.raagin@gmail.com",
1111
description="StreamField for native Django Admin or with Grappelli",
@@ -15,6 +15,7 @@
1515
packages=setuptools.find_packages(exclude=['test_project']),
1616
include_package_data=True,
1717
zip_safe=False,
18+
python_requires='>=3',
1819
classifiers=[
1920
"Programming Language :: Python :: 3",
2021
'License :: OSI Approved :: BSD License',

streamfield/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name = "streamfield"
2-
VERSION = '1.1.1'
2+
VERSION = '1.1.2'

0 commit comments

Comments
 (0)