Skip to content

PetrDlouhy/django-price-level

Repository files navigation

django-price-level

https://badge.fury.io/py/django-price-level.png https://travis-ci.org/PetrDlouhy/django-price-level.png?branch=master

Adds time limited price levels to your model class.

Documentation

The full documentation is at https://django-price-level.readthedocs.io.

Quickstart

Install django-price-level:

pip install django-price-level

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'price_level',
    ...
)

Configure in your settings the desired model:

from model_utils import Choices
PRICE_LEVEL_MODEL = 'your.Model'
PRICE_LEVEL_CATEGORY_CHOICES = Choices(('basic', _('Basic')), ('company', _('For companies')))
PRICE_LEVEL_CATEGORY_DEFAULT = 'basic'

Add author middleware in settings:

MIDDLEWARE_CLASSES = [
    ...
    'author.middlewares.AuthorDefaultBackendMiddleware',
    ...
 ]

Use Pricable behavioral mixin to your model:

from price_level.models import Pricable
class Model(Pricable, models.Model):
   ...

Now you can get current price for your category:

price_level = model.get_current_price_level(category='company')

Features

  • Adds PriceLevel models can be bound to your model class

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published