Metadata-Version: 2.1
Name: django-utils2
Version: 2.9.0
Summary: Django Utils is a module with some convenient utilities not included with the standard Django install
Home-page: https://github.com/WoLpH/django-utils
Author: Rick van Hattem
Author-email: Rick.van.Hattem@Fawo.nl
License: BSD
Platform: UNKNOWN
Classifier: Development Status :: 6 - Mature
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: python-utils (>=2.0.1)
Requires-Dist: anyjson (>=0.3.0)
Provides-Extra: docs
Requires-Dist: django ; extra == 'docs'
Requires-Dist: mock ; extra == 'docs'
Requires-Dist: sphinx (>=1.7.2) ; extra == 'docs'
Provides-Extra: tests
Requires-Dist: sphinx ; extra == 'tests'
Requires-Dist: pytest ; extra == 'tests'
Requires-Dist: pytest-cache ; extra == 'tests'
Requires-Dist: pytest-cov ; extra == 'tests'
Requires-Dist: pytest-django ; extra == 'tests'
Requires-Dist: pytest-flake8 ; extra == 'tests'
Requires-Dist: jinja2 ; extra == 'tests'
Requires-Dist: pygments ; extra == 'tests'

Introduction
============

Travis status:

.. image:: https://travis-ci.org/WoLpH/django-utils.png?branch=master
  :target: https://travis-ci.org/WoLpH/django-utils

Coverage:

.. image:: https://coveralls.io/repos/WoLpH/django-utils/badge.png?branch=master
  :target: https://coveralls.io/r/WoLpH/django-utils?branch=master

Django Utils is a collection of small Django helper functions, utilities and
classes which make common patterns shorter and easier. It is by no means a
complete collection but it has served me quite a bit in the past and I will
keep extending it.

Examples are:

 - Enum based choicefields
 - Models with automatic `__str__`, `__unicode__` and `__repr__` functions
   based on names and/or slugs using simple mixins.
 - Models with automatic `updated_at` and `created_at` fields
 - Models with automatic slugs based on the `name` property.
 - Iterating through querysets in predefined chunks to prevent out of memory
   errors

The library depends on the Python Utils library.

Documentation is available at: http://django-utils-2.readthedocs.io/en/latest/

Install
-------

To install:

 1. Run `pip install django-utils2` or execute `python setup.py install` in the source directory
 2. Add `django_utils` to your `INSTALLED_APPS`

If you want to run the tests, run `py.test` (requirements in `tests/requirements.txt`)


Usage
-----

To enable easy to use choices which are more convenient than the Django 3.0 choices system you can use this:

.. code-block:: python

    from django_utils import choices


    # For manually specifying the value (automatically detects `str`, `int` and `float`):
    class Human(models.Model):
        class Gender(choices.Choices):
            MALE = 'm'
            FEMALE = 'f'
            OTHER = 'o'

        gender = models.CharField(max_length=1, choices=Gender)


    # To define the values as `male` implicitly:
    class Human(models.Model):
        class Gender(choices.Choices):
            MALE = choices.Choice()
            FEMALE = choices.Choice()
            OTHER = choices.Choice()

        gender = models.CharField(max_length=1, choices=Gender)


    # Or explicitly define them
    class Human(models.Model):
        class Gender(choices.Choices):
            MALE = choices.Choice('m', 'male')
            FEMALE = choices.Choice('f', 'female')
            OTHER = choices.Choice('o', 'other')

        gender = models.CharField(max_length=1, choices=Gender)

A PostgreSQL ENUM field will be coming soon to automatically facilitate the creation of the enum if needed.

Links
-----

* Documentation
    - http://django-utils-2.readthedocs.org/en/latest/
* Source
    - https://github.com/WoLpH/django-utils
* Bug reports 
    - https://github.com/WoLpH/django-utils/issues
* Package homepage
    - https://pypi.python.org/pypi/django-utils2
* My blog
    - http://w.wol.ph/



