This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Tiny app to provide basic behaviors for django models, like:

  • Timestampable
  • Publishable
  • SoftDeletable
  • Cacheable

Installation

From PyPI:

$ pip install django-basic-models-behaviors

Usage

PublishableModel

Here is an example of Article using PublishableModel:

from basic_models_behaviors import models as behaviors
from django.db import models

class Article(behaviors.PublishableModel):
    title = models.CharField(max_length=255)
    contents = models.TextField()

Then:

>>> article = Article(title='Foo', contents='Lorem lipsum')
>>> article.publish()
>>> article.is_published()
True
>>> article.unpublish()
>>> article.is_published()
False
>>> article.is_not_published()
True

SoftDeletableModel

SoftDeletableModel behavior will add deleted_at field in set the current timestamp instead of delete the object. force_delete() will actually delete the model.

In your models.py:

from basic_models_behaviors import models as behaviors
from django.db import models

class Article(behaviors.SoftDeletableModel):
    title = models.CharField(max_length=255)
    contents = models.TextField()

Then:

>>> from models import Article
>>> article = Article(title='foo', contents='Lorem lipsum')
>>> article.delete()
>>> article.has_been_deleted()
True
>>> article.undelete()
>>> article.has_been_deleted()
False
>>> article.force_delete()

Tests

Run tests:

$ pip install -r tests/requirements.txt
$ py.test --ds=tests.settings tests

Authors

Release History

Release History

0.6.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.5.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-basic-models-behaviors-0.6.0.tar.gz (7.4 kB) Copy SHA256 Checksum SHA256 Source Mar 22, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting