django-easy-autoslug


Namedjango-easy-autoslug JSON
Version 1.0.4 PyPI version JSON
download
home_page
SummaryAutomatic slug for django
upload_time2023-01-23 17:39:11
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT
keywords slug django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======================================
Automatic slug generation from content
======================================

|codecov| |version| |downloads| |license|

This package is used to automatically create unique slugs.

Install
-------

.. code:: bash

	pip install django-easy-autoslug

Usage
-----

Basic example
^^^^^^^^^^^^^

.. code:: python

	# models.py

	from django_autoslugfield import AutoSlugField

	class Item(models.Model):
		title = models.CharField(max_length=255)
		slug = AutoSlugField(max_length=255, unique=True)

Slug is created from ``__str__`` method. If another object with same slug
already exists slug will be suffixed with number ``-2``, ``-3`` …

Advanced usage
^^^^^^^^^^^^^^

AutoSlugField arguments are:

* `reserve_chars` - number of characters reserved for suffix (including sparator
  ``-``)
* `title_field` - use specific field instread of `__str__` method
* `in_respect_to` - generate unique slug for specific subset of fields

Following code can create same slug for another month / year.

.. code:: python

	from django_autoslugfield import AutoSlugField

	class Blog(models.Model):
		title = models.CharField(max_length=255)
		slug = AutoSlugField(filter_fields=('year', 'month'), max_length=255)
		year = models.IntegerField()
		month = models.IntegerField()

		class Meta:
			unique_together = ('slug', 'year', 'month')


.. |codecov| image:: https://codecov.io/gh/mireq/django-autoslugfield/branch/master/graph/badge.svg?token=T801PBRI31
	:target: https://codecov.io/gh/mireq/django-autoslugfield

.. |version| image:: https://badge.fury.io/py/django-easy-autoslug.svg
	:target: https://pypi.python.org/pypi/django-easy-autoslug/

.. |downloads| image:: https://img.shields.io/pypi/dw/django-easy-autoslug.svg
	:target: https://pypi.python.org/pypi/django-easy-autoslug/

.. |license| image:: https://img.shields.io/pypi/l/django-easy-autoslug.svg
	:target: https://pypi.python.org/pypi/django-easy-autoslug/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-easy-autoslug",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "slug,django",
    "author": "",
    "author_email": "Miroslav Bend\u00edk <miroslav.bendik@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/89/49/cd7cc9cdba51d3d2b24f8efa182f4ac70bd7b69afbece1ebccd59aa42139/django_easy_autoslug-1.0.4.tar.gz",
    "platform": null,
    "description": "======================================\nAutomatic slug generation from content\n======================================\n\n|codecov| |version| |downloads| |license|\n\nThis package is used to automatically create unique slugs.\n\nInstall\n-------\n\n.. code:: bash\n\n\tpip install django-easy-autoslug\n\nUsage\n-----\n\nBasic example\n^^^^^^^^^^^^^\n\n.. code:: python\n\n\t# models.py\n\n\tfrom django_autoslugfield import AutoSlugField\n\n\tclass Item(models.Model):\n\t\ttitle = models.CharField(max_length=255)\n\t\tslug = AutoSlugField(max_length=255, unique=True)\n\nSlug is created from ``__str__`` method. If another object with same slug\nalready exists slug will be suffixed with number ``-2``, ``-3`` \u2026\n\nAdvanced usage\n^^^^^^^^^^^^^^\n\nAutoSlugField arguments are:\n\n* `reserve_chars` - number of characters reserved for suffix (including sparator\n  ``-``)\n* `title_field` - use specific field instread of `__str__` method\n* `in_respect_to` - generate unique slug for specific subset of fields\n\nFollowing code can create same slug for another month / year.\n\n.. code:: python\n\n\tfrom django_autoslugfield import AutoSlugField\n\n\tclass Blog(models.Model):\n\t\ttitle = models.CharField(max_length=255)\n\t\tslug = AutoSlugField(filter_fields=('year', 'month'), max_length=255)\n\t\tyear = models.IntegerField()\n\t\tmonth = models.IntegerField()\n\n\t\tclass Meta:\n\t\t\tunique_together = ('slug', 'year', 'month')\n\n\n.. |codecov| image:: https://codecov.io/gh/mireq/django-autoslugfield/branch/master/graph/badge.svg?token=T801PBRI31\n\t:target: https://codecov.io/gh/mireq/django-autoslugfield\n\n.. |version| image:: https://badge.fury.io/py/django-easy-autoslug.svg\n\t:target: https://pypi.python.org/pypi/django-easy-autoslug/\n\n.. |downloads| image:: https://img.shields.io/pypi/dw/django-easy-autoslug.svg\n\t:target: https://pypi.python.org/pypi/django-easy-autoslug/\n\n.. |license| image:: https://img.shields.io/pypi/l/django-easy-autoslug.svg\n\t:target: https://pypi.python.org/pypi/django-easy-autoslug/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Automatic slug for django",
    "version": "1.0.4",
    "split_keywords": [
        "slug",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a5bba58de8fa04e12f43c2c87d7694e92476dc51f3ba3313e4d5abe4eaeeb6c",
                "md5": "2fa165607a5ca373b8114e45dae3c6ca",
                "sha256": "f9b631d8a7151742307abf7b78a2ec5744252753a1f797d78f1e99a679cf20f6"
            },
            "downloads": -1,
            "filename": "django_easy_autoslug-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fa165607a5ca373b8114e45dae3c6ca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5728,
            "upload_time": "2023-01-23T17:39:09",
            "upload_time_iso_8601": "2023-01-23T17:39:09.826512Z",
            "url": "https://files.pythonhosted.org/packages/5a/5b/ba58de8fa04e12f43c2c87d7694e92476dc51f3ba3313e4d5abe4eaeeb6c/django_easy_autoslug-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8949cd7cc9cdba51d3d2b24f8efa182f4ac70bd7b69afbece1ebccd59aa42139",
                "md5": "c4d0094133261feb15279fca94385118",
                "sha256": "1201e2a5285147193c45377d276c4f13ce6f482291bc75ecc45c14146f370666"
            },
            "downloads": -1,
            "filename": "django_easy_autoslug-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "c4d0094133261feb15279fca94385118",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14182,
            "upload_time": "2023-01-23T17:39:11",
            "upload_time_iso_8601": "2023-01-23T17:39:11.549388Z",
            "url": "https://files.pythonhosted.org/packages/89/49/cd7cc9cdba51d3d2b24f8efa182f4ac70bd7b69afbece1ebccd59aa42139/django_easy_autoslug-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-23 17:39:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "django-easy-autoslug"
}
        
Elapsed time: 0.03226s