Browse files

added choices

  • Loading branch information...
1 parent af02120 commit efca950a8ca433b9430a4d6c843760ddf9bc6d00 @WoLpH committed Aug 28, 2013
Showing with 63 additions and 12 deletions.
  1. +1 −1 django_utils/__init__.py
  2. +43 −0 django_utils/choices.py
  3. +10 −10 docs/conf.py
  4. +9 −1 docs/django_utils.rst
View
2 django_utils/__init__.py
@@ -1,5 +1,5 @@
__package_name__ = 'django_utils2'
-__version__ = '1.1'
+__version__ = '1.2'
__author__ = 'Rick van Hattem'
__author_email__ = 'Rick.van.Hattem@Fawo.nl'
__description__ = (
View
43 django_utils/choices.py
@@ -1,3 +1,46 @@
+'''
+Usage
+------------------------------------------------------------------------------
+
+Create a :py:class:`Choices` class and add :py:class:`Choice` objects to the
+class to define your choices.
+
+Example:
+
+The normal Django version:
+
+.. code-block:: python
+
+ class Human(models.Model):
+ GENDER = (
+ ('m', 'Male'),
+ ('f', 'Female'),
+ ('o', 'Other'),
+ )
+ gender = models.CharField(max_length=1, choices=GENDER)
+
+The Django Utils Choices version:
+
+.. code-block:: python
+
+ from django_utils import choices
+
+ class Human(models.Model):
+ class Gender(choices.Choices):
+ Male = choices.Choice('m')
+ Female = choices.Choice('f')
+ Other = choices.Choice('o')
+
+ gender = models.CharField(max_length=1, choices=Gender.choices)
+
+To reference these properties:
+
+.. code-block:: python
+
+ Human.create(gender=Human.Gender.Male)
+
+'''
+
import collections
View
20 docs/conf.py
@@ -47,7 +47,7 @@
master_doc = 'index'
# General information about the project.
-project = django_utils.__name__.replace('-', ' ').capitalize()
+project = django_utils.__package_name__.replace('-', ' ').capitalize()
copyright = u'%s, %s' % (
datetime.date.today().year,
django_utils.__author__,
@@ -174,7 +174,7 @@
# html_file_suffix = None
# Output file base name for HTML help builder.
-htmlhelp_basename = django_utils.__name__ + '-doc'
+htmlhelp_basename = django_utils.__package_name__ + '-doc'
# -- Options for LaTeX output --------------------------------------------
@@ -194,8 +194,8 @@
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [(
'index',
- '%s.tex' % django_utils.__name__,
- u'%s Documentation' % django_utils.__name__.replace('-', ' ').capitalize(),
+ '%s.tex' % django_utils.__package_name__,
+ u'%s Documentation' % django_utils.__package_name__.replace('-', ' ').capitalize(),
django_utils.__author__,
'manual',
)]
@@ -227,8 +227,8 @@
# (source start file, name, description, authors, manual section).
man_pages = [(
'index',
- django_utils.__name__,
- u'%s Documentation' % django_utils.__name__.replace('-', ' ').capitalize(),
+ django_utils.__package_name__,
+ u'%s Documentation' % django_utils.__package_name__.replace('-', ' ').capitalize(),
[django_utils.__author__],
1,
)]
@@ -244,10 +244,10 @@
# dir menu entry, description, category)
texinfo_documents = [(
'index',
- django_utils.__name__,
- u'%s Documentation' % django_utils.__name__.replace('-', ' ').capitalize(),
+ django_utils.__package_name__,
+ u'%s Documentation' % django_utils.__package_name__.replace('-', ' ').capitalize(),
django_utils.__author__,
- django_utils.__name__,
+ django_utils.__package_name__,
django_utils.__description__,
'Miscellaneous',
)]
@@ -265,7 +265,7 @@
# -- Options for Epub output ---------------------------------------------
# Bibliographic Dublin Core info.
-epub_title = django_utils.__name__.replace('-', ' ').capitalize()
+epub_title = django_utils.__package_name__.replace('-', ' ').capitalize()
epub_author = django_utils.__author__
epub_publisher = django_utils.__author__
epub_copyright = copyright
View
10 docs/django_utils.rst
@@ -4,7 +4,7 @@ django_utils Package
:mod:`django_utils` Package
---------------------------
-.. automodule:: django_utils.__init__
+.. automodule:: django_utils
:members:
:undoc-members:
:show-inheritance:
@@ -17,6 +17,14 @@ django_utils Package
:undoc-members:
:show-inheritance:
+:mod:`choices` Module
+-------------------------
+
+.. automodule:: django_utils.choices
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
:mod:`queryset` Module
----------------------

0 comments on commit efca950

Please sign in to comment.