{ "info": { "author": "Ben Tappin", "author_email": "ben@mrben.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Utilities" ], "description": "django-utensils\n===============\n\nA collection of reusable components to help build Django projects.\n\nInstallation\n------------\n\nTo install the latest stable release:\n\n::\n\n pip install django-utensils\n\nTo get the latest dev version, install directly form GitHub like so:\n\n::\n\n pip install -e git://github.com/code-kitchen/django-utensils.git#egg=django-utensils\n\nMany of the template tags require the ``request`` object. You need to\nadd 'django.template.context\\_processors.request' (Django 1.6 and 17) or\n'django.template.context\\_processors.request' (Django 1.8) to the\ntemplate context processors in your settings.\n\nTo use the ``AddressedModel`` you will need to add ``countries_plus`` to\nyour ``INSTALLED_APPS`` setting.\n\nForms\n-----\n\n``SearchForm``\n~~~~~~~~~~~~~~\n\nGeneric search form that can be used on any page.\n\nUsed by ``viewmixins.SearchFormMixin``.\n\n``UniqueModelFieldsMixin``\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nMixin that enforces unique fields on ModelForm form fields.\n\nMust be left of ModelForm when defining the form class (see\nhttps://code.djangoproject.com/ticket/13075).\n\nThere are two ways to list your unique fields depending on whether or\nnot you want case insensitivity.\n\n.. code:: python\n\n unique_fields = ['name', 'username']\n unique_fields = ['name', {'field': 'username', 'case_insensitive': True}]\n\nMiddleware\n----------\n\nHidden site\n~~~~~~~~~~~\n\nBy adding ``utensils.middleware.HiddenSiteMiddleware`` to your\n``MIDDLEWARE_CLASSES`` you can prevent people from viewing your site\nunless they use a query string parameter. The parameter is not needed\nfor subsequent visits (unless cookies are cleared). This is a quick and\nsimple method to keep prying eyes off your staging server for example.\nProvide the parameter name in the settings variable\n``HIDDEN_SITE_SECRET``.\n\nFor example:\n\n.. code:: python\n\n MIDDLEWARE_CLASSES += ('utensils.middleware.HiddenSiteMiddleware',)\n HIDDEN_SITE_SECRET = 'whisky'\n\nUsing the built-in development server browsing to http://localhost/ will\ngive the message \"ACCESS DENIED\". Browing to http://localhost/?whisky\nwill succeed. Subsequent visits to http://localhost/ (no ``?whisky``)\nwith the same browser will succeed until cookies are cleared or the\ncookie expires (currently set to a year).\n\nView mixins\n-----------\n\nCollection of mixins for class-based views.\n\nList view pagination\n~~~~~~~~~~~~~~~~~~~~\n\nThe ``PaginateMixin`` returns the paginate by setting used by the\npagination template tag ``{% pagination %}`` so the Django ``ListView``\nfunctions can use it.\n\nYou will need to add ``utensils.context_processors.pagination`` to your\ncontext processors for the template tag to work. Set\n``settings.PAGINATION_PAGE_SIZES`` to control the page size, if not set\nthe default ``[20, 50, 100]`` is used.\n\nList view ordering\n~~~~~~~~~~~~~~~~~~\n\nThe ``OrderByMixin`` allows easy ordering of list views. By including it\nthe template tag (``{% order_by 'field_name' %}``) is given sorting\ncontext variables to work with. ``get_queryset`` is overidden to make\nuse of these and order the object list.\n\nGeneric single-field search\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe ``SearchFormMixin`` provides a handy way to add search to list\nviews. Add the ``search_form`` manually in your template or use the\nincluded fragment ``{% include 'fragments/_search.html' %}``.\n\nSpecify the fields you wish to search on, and how, by including a\n``search_fields`` dictionary on your view like so:\n\n.. code:: python\n\n class CustomerListView(SearchFormMixin, ListView):\n model = Customer\n search_fields = {\n 'user__email': 'icontains',\n 'first_name': 'icontains',\n 'last_name': 'icontains',\n 'postal_code': 'icontains',\n }\n\n``MessageMixin``\n~~~~~~~~~~~~~~~~\n\nBy including and providing ``success_message`` and/or ``error_message``\nattributes on your view class, messages will be added automatically to\nthe request objects on events suchs as valid and invalid forms and\nformsets, object deletion etc.\n\n``PermissionRequiredMixin``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThis mixin verfies the user is logged in and has the required\npermissions to access the view. It's a modified version of the\ndjango-braces mixin with an added bypass. Setting\n``permission_required = False`` allows you to skip the check whilst\nkeeping the mixin in a base view used across a project, for example.\n\nSettings:\n\n- ``permission_required`` - the permission to check for or False to\n skip check\n- ``login_url`` - the login url of site\n- ``redirect_field_name`` - defaults to \"next\"\n- ``raise_exception`` - defaults to False - raise 403 if set to True\n\n``RedirectToNextMixin``\n~~~~~~~~~~~~~~~~~~~~~~~\n\nIf a ``next`` query string parameter is preset on a ``post()`` call it\nis assigned to the instance ``success_url``.\n\n``StaffViewMixin``\n~~~~~~~~~~~~~~~~~~\n\nCombines ``MessageMixin``, ``RedirectToNextMixin``,\n``StaffuserRequiredMixin`` (from django-brances),\n``PermissionRequiredMixin`` to create a useful mixin that can be used on\nall staff views.\n\nViews\n-----\n\n``BaseListView``\n~~~~~~~~~~~~~~~~\n\nThis view combines the pagination, order by and search mixins and adds\nan optional query set filter description that your templates can use.\n\n.. code:: python\n\n class ActiveCustomerList(BaseListView):\n filter_description = u\"Active\"\n queryset = Customer.active.all()\n\n.. code:: html\n\n {% block content %}\n