The missing gamification plugin for Django
Project description
# Django Gamification
[![PyPI version](https://badge.fury.io/py/django-gamification.svg)](https://badge.fury.io/py/django-gamification)
Django Gamification aims to fill the gamification sized whole in the Django package ecosystem. In the current state, Django Gamification provides a set of models that can be used to implement gamification features in your application. These include a centralised interface for keeping track of all gamification related objects including badges, points, and unlockables.
## Installation
```
pip install django_gamification
```
## Features and Examples
### Concepts
Django Gamification requires the understanding of a few core concepts.
- **BadgeDefinitions:** A template used to create new Badges and update existing Badges.
- **Badge:** An object that represents some achievable objective in the system that can award points and track its own progression.
- **UnlockableDefinition:** A template used to create new Unlockables and update existing Unlockables.
- **Unlockable:** An object that is achieved by some accumulation of points.
- **Category:** An object used to label other objects like Badges via their BadgeDefinition.
### Interfaces
#### Creating an interface
```python
from django.contrib.auth.models import User
from django.db import models
from django_gamification.models import GamificationInterface
class YourUserModel(models.User):
# Your user fields here
# The gamification interface
interface = models.ForeignKey(GamificationInterface)
```
### BadgeDefinitions and Badges
### Creating a new badge
By creating a new `BadgeDefinition`, Django Gamification will automatically create `Badge` instances for all your current `GamificationInterfaces` with `Badge.name`, `Badge.description`, `Badge.points`, `Badge.progression` and `Badge.category` mimicking the fields on the `BadgeDefinition`.
```python
from django_gamification.models import BadgeDefinition, Category
BadgeDefinition.objects.create(
name='Badge of Awesome',
description='You proved your awesomeness',
points=50,
progression_target=100,
category=Category.objects.create(name='Gold Badges', description='These are the top badges'),
)
```
### Awarding a badge
You can manually award a `Badge` instance using `Badge.award()`.
```python
from django_gamification.models import Badge
badge = Badge.objects.first()
# badge.acquired = False
badge.award()
# badge.acquired = True
```
### UnlockableDefinitions and Unlockables
### Creating a new unlockable
By creating a new `UnlockableDefinition`, Django Gamification will automatically create `Unlockable` instances for all your current `GamificationInterfaces` with `Unlockable.name`, `Unlockable.description`, `Unlockable.points_required` mimicking the fields on the `UnlockableDefinition`.
```python
from django_gamification.models import UnlockableDefinition
UnlockableDefinition.objects.create(
name='Some super sort after feature',
description='You unlocked a super sort after feature',
points_required=100
)
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django_gamification-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50dc814afa1404d3405b2f1369081b36f3797c73f2069238aaed501b6f65a0cb |
|
MD5 | 58fcdb2e8206c5b424c1a1f23f03266d |
|
BLAKE2b-256 | f2b4aeffc6a7a3e1779a69ea60b5b8d8f7e7ed1c2b49012c1bbeccc983c442f3 |
Close
Hashes for django_gamification-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 711cd59bee70480d0e3824992393a7c39ca7f30add3d9c9c39073f08c911987c |
|
MD5 | 80580b39fd6f9fa84e24ba8b5a3bf59e |
|
BLAKE2b-256 | 2c254d84443a2eb856f4fe9a67cd8e3f6ee5746d31e2e0848679cb118dbb9df4 |