Metadata-Version: 2.1
Name: django-easy-autoslug
Version: 1.0.0
Summary: Automatic slug for django
Author-email: Miroslav Bendík <miroslav.bendik@gmail.com>
License: MIT
Project-URL: homepage, https://github.com/mireq/django-autoslugfield
Project-URL: documentation, https://github.com/mireq/django-autoslugfield
Project-URL: repository, https://github.com/mireq/django-autoslugfield
Project-URL: changelog, https://github.com/mireq/django-autoslugfield/blob/master/CHANGELOG.md
Keywords: slug,django
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
Provides-Extra: dev
License-File: LICENSE
License-File: AUTHORS

======================================
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/
