{ "info": { "author": "HZDG", "author_email": "webmaster@hzdg.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "Installation\n------------\n\n1. ``pip install django-modeltools``\n\n\nIncluded Tools\n--------------\n\n\nEnum\n````\n\nThe ``Enum`` class lets you quickly define enumeration types for model field values. The constructor accepts kwargs where the key is the name of the \"constant\" and the value is a two-tuple containing the value of the constant (which will be stored in the database) and a label.\n\nUsage\n'''''\n\nIn models.py:\n\n.. code-block:: python\n\n\tfrom modeltools import Enum\n\n\tclass MyModel(models.Model):\n\n\t Color = Enum(\n\t RED=('r', 'Red'),\n\t GREEN=('g', 'Green'),\n\t BLUE=('b', 'Blue'),\n\t )\n\n\t color = models.CharField(max_length=1, choices=Color.choices())\n\nElsewhere:\n\n.. code-block:: python\n\n\tm = MyModel.objects.filter(color=MyModel.Color.RED)\n\n\nformat_filename\n```````````````\n\nThe ``format_filename`` function provides an easy way to name user media (uploaded files) based on properties of the model that stores them.\n\nUsage\n`````\n\nIn models.py:\n\n.. code-block:: python\n\n\tfrom modeltools import format_filename as _ff\n\n\tclass Person(models.Model):\n\t\tfirst_name = models.CharField(max_length=50)\n\t\tlast_name = models.CharField(max_length=50)\n\t\tmiddle_name = models.CharField(max_length=50)\n\t\tavatar = models.ImageField(upload_to=_ff('avatars/{last_name}_{first_name}'))\n\nIn the above example, ``{first_name}`` and ``{last_name}`` will be replaced with the corresponding values from the ``Person`` instance. The uploaded file will automatically retain its original extension.\n\n.. code-block:: python\n\n\tupload_to=_ff('avatars/{last_name}_{first_name}/{__filename}.thumbnail{__ext}')\n\n``{__filename}`` and ``{__ext}`` allows access to the name and extension the file was uploaded with.\n\nBy default, the properties used in the formatting pattern will be converted to lowercase, stripped of non-word characters, and have their spaces replaced with underscores. (This behavior can be changed by providing extra arguments to the ``format_filename`` function.) The rest of the formatting string will be unaffected.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hzdg/django-modeltools", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-modeltools", "package_url": "https://pypi.org/project/django-modeltools/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-modeltools/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/hzdg/django-modeltools" }, "release_url": "https://pypi.org/project/django-modeltools/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "A collection of utilities that make dealing with Django models more fun.", "version": "1.0.1" }, "last_serial": 3651980, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "25c09ebe28a33feeb5a052df7a0739cd", "sha256": "f1b37b509367b4487dd7f35a798021533f67eb2ec97c1f763099c5bb01af8180" }, "downloads": -1, "filename": "django-modeltools-1.0.0.tar.gz", "has_sig": false, "md5_digest": "25c09ebe28a33feeb5a052df7a0739cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6085, "upload_time": "2013-08-01T20:51:03", "url": "https://files.pythonhosted.org/packages/9e/f6/e70882ebb9ca24378982615b745464d80a8995562b343e099f8fc10a7ce5/django-modeltools-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "9d1d4fef8549fc161b3a9b5c93566508", "sha256": "5398bd473e53913cd027f8642b70dce40132cc3f6469cffc85cfcebddf2d5e63" }, "downloads": -1, "filename": "django-modeltools-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9d1d4fef8549fc161b3a9b5c93566508", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5144, "upload_time": "2013-11-13T18:47:25", "url": "https://files.pythonhosted.org/packages/70/63/10daacc2ac4d381d9f58d6f8212be5581a242db2df24818f055d8e0f1cec/django-modeltools-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9d1d4fef8549fc161b3a9b5c93566508", "sha256": "5398bd473e53913cd027f8642b70dce40132cc3f6469cffc85cfcebddf2d5e63" }, "downloads": -1, "filename": "django-modeltools-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9d1d4fef8549fc161b3a9b5c93566508", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5144, "upload_time": "2013-11-13T18:47:25", "url": "https://files.pythonhosted.org/packages/70/63/10daacc2ac4d381d9f58d6f8212be5581a242db2df24818f055d8e0f1cec/django-modeltools-1.0.1.tar.gz" } ] }