Skip to main content
[![Build Status](https://travis-ci.org/dlapiduz/django-widgeter.png?branch=master)](https://travis-ci.org/dlapiduz/django-widgeter)

Widgeter
========================

A simple engine for django backend widgets based on https://github.com/marcinn/django-widgets.


Features
-----------------

- Creation of custom widgets in reusable apps
- Rendering of widgets by name
- Rendering of widget blocks without previous knowledge of widget names
- Autodiscovery of widgets from all installed apps


Installation
-----------------

1. Install the package using `pip install django-widgeter`
1. Add `widgeter` to your `INSTALLED_APPS` in `settings.py`


Defining a Widget
-----------------

Add a `widgets.py` file on your application with the following statements.

- Widgets can be defined with a template (and optionally a context):
```
from widgeter.base import Widget

class HelloWorld(Widget):
template = 'hello_world/widget.html'

def get_context(self, context, options=None):
return { 'message': u'Hello World!' }
```

or with a render function:
```
from widgeter.base import Widget

class HelloWorld(Widget):
def render(self, context, options=None):
return u'Hello world!'

```
- Register your widget:
```
from widgeter.registry import registry

registry.register('hello_world', HelloWorld())
```


Rendering a Widget
-----------------

On a template you first have to load the template tags and then render the particular widget:

```
{% load widgeter %}
{% widget "hello_world" %}
```

You can also pass variables to your widget:

```
{% load widgeter %}
{% widget "hello_world" current_user %}
```


Using Blocks
-----------------

Widget blocks allow you to render widgets without previously knowing the names for them.
The autodiscovery process will add them to the registry and you can the look them up by block name.
Priorities can also be assigned to render them in order.

- First define a block on the widget:
```
from widgeter.base import Widget

class HelloWorld(Widget):
block = 'home'
priority = '1'
template = 'hello_world/widget.html'

def get_context(self, context, options=None):
return { 'message': u'Hello World!' }
```

- Then, on the template, use the `widget_block` tag:
```
{% load widgeter %}
{% widget_block "home" current_user %}
```

Running the Tests
------------------------------------

You can run the tests with via::

python setup.py test

or::

python runtests.py

Metadata

Release files for django-widgeter 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-widgeter 0.1
File Size Uploaded Provenance Actions
django-widgeter-0.1.tar.gz 4.2 kB Without provenance Details for django-widgeter-0.1.tar.gz

Release files / django-widgeter-0.1.tar.gz

Download URL django-widgeter-0.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
607ebe7b5adccd7f18f2b560bf1d1340b78324a3ad879817649b13a793258ac8
BLAKE2b-256 checksum
How to use checksums
a806d1cceb86d5292a9ef70a28d68e5d864fe5062e6939ac1c070cfd33a216ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-widgeter 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page