{ "info": { "author": "Alexander Ivanov", "author_email": "alexander.ivanov@redsolution.ru", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Buildout", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: Russian", "Operating System :: Microsoft :: Windows", "Operating System :: Unix", "Programming Language :: Python :: 2.5", "Topic :: Software Development :: Version Control" ], "description": "================\ndjango-utilities\n================\n\nA set of Django useful utilities.\n\n* ImageField with preview in admin interface\n* Override allows to create users with dot in username\n* Localized date filter\n* ConsoleException middleware\n\nInstallation:\n=============\n\n1. Put ``utilities`` in to your ``INSTALLED_APPS`` in your ``settings.py`` within your django project.\n\nUsage:\n======\n\nImagePreviewField:\n------------------\n\nUsed to show image preview near ImageField.\n\nTo use it in your ``models.py`` ::\n\n\tfrom utilities.fields import ImagePreviewFieldd\n\n\tclass MyModel(models.Model):\n\t\timage = ImagePreviewField(upload_to='upload/')\n\nYou can specify maximum width and height for the thumb ::\n\n\tclass MyModel(models.Model):\n\t\timage = ImagePreviewField(upload_to='upload/', thumb_size=(80, 80))\n\n\nIf you have separated field with thumb for this image you can specify its name and told to use its real size::\n\n\tclass MyModel(models.Model):\n\t\tthumb = models.ImageField(upload_to='thumb/')\n\t\timage = ImagePreviewField(upload_to='upload/', thumb_field='thumb', thumb_size=None)\n\nDot is username:\n----------------\n\nBy default this application will allow you to create users in admin with dot in there names.\nTo disallow set ``ALLOW_DOT_IS_USERNAME`` to ``False`` in your ``settings.py``. \n\n\nLocal date template filter:\n---------------------------\n\nThe ``date_local`` filter supposed to be used with Django 1.1 (1.2+ already has such feature ).\nLoad filter with ``{% load utilities_tags %}`` and use it like date `Django date filter`_ \n\nFor example: ::\n\n\t{{ entry.creation_date|date_local:\"d F Y\" }}\n\nReturns 01 \u042f\u043d\u0432\u0430\u0440\u044f 2010 for ``ru`` locale\n\nConsoleException middleware:\n----------------------------\n\nOften you get annoyed when Django show Tracebacks like ::\n \n File \"/home/mysite/django-mysite3/django/template/__init__.py\", line\n 800, in render_node\n return node.render(context)\n\nConsoleException middleware prints original tracebacks in STDOUT. It is very helpful\nfor debugging sometimes. \nUse it **ONLY** in development mode!\n\nReset password form:\n--------------------\n\nTo enable password reset form, set in your ``settings.py``::\n\n ENABLE_PASSWORD_RESET = True\n\nAnd include utilities urls into your urlconf::\n\n urlpatterns += patterns('',\n (r'^', include('utilities.urls')),\n )\n\nYou will get link to password reset in users administration section under email\nfield.\nWhen you reset password to some user, all his or her active sessions will be \ndeleted, password will be set to unusable.\nThe only way to login is follow link, provided in email.\nIf user has no email, you will not able reset password for this user.\n\nSplitDateField:\n---------------\n\nYou can specify minimal and maximum date with attributes ``from_date`` (default\n``datetime.date(1930,01,01)``) and ``till_date`` (default ``datetime.date.today``)\n, they must have date type or be callable object. Also you may reverse order of \nyears with help of boolean attribute ``reverse`` (default False).\n\nIf ``from_date=datetime.date(2007,01,01)``, ``till_date=datetime.date(2010,01,01)`` \nand ``reverse=False``, then we obtain the sequence of years: 2007, 2008, 2009, 2010\n\nTo use it in your ``models.py`` ::\n\n from utilities.fields import SplitDateField\n \n class MyModel(models.Model):\n date = SplitDateField(from_date=datetime.date(2008,10,01),\n till_date=datetime.date.today, reverse=True)\n \nTo use it in your ``forms.py`` ::\n\n from utilities.fields import SplitDateFormField\n \n class MyForm(forms.Form)\n date = SplitDateFormField(from_date=datetime.date(2008,10,01),\n till_date=datetime.date.today, reverse=True)\n\n\nManagement commands:\n--------------------\n\nSince 0.1.4 few management commands added:\n\n**imagekit_recache**\n Re-create cache for imagekit models. Command has --force option to delete old cache dir.\n\n**update_permissions**\n Update permissions for installed models. Useful if you change permissions in project's lifecycle.\n\n\nAJAX CRSF:\n----------\n\nDjango CSRF protection (https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax) documentation\n offer solution to set CSRF headers to ajax requests on site. That solution copied into utulities\n script to avoid copy-paste.::\n\n