Metadata-Version: 2.4
Name: django-randomslugfield
Version: 0.3.0.post1
Summary: A Django field that automatically generates random slugs.
License-Expression: MIT
Project-URL: Source, http://github.com/mkrjhnsn/django-randomslugfield
Classifier: Development Status :: 7 - Inactive
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

> **DO NOT USE!**
>
> This project is no longer maintained.
>
> It was originally made to replicate the style of URL you find on many websites to obfuscate integer based primary keys.
> However the implementation relies on expensive database lookups to prevent collisions.
>
> A better/modern alternative to this project would be something using [sqids](https://sqids.org/).


# django-randomslugfield

Django field that automatically generates random slugs.

e.g. *example.com/kEwD58P*

Tested with Python 2.7, 3.3+ and Django 1.4+.


## Getting it

To install django-randomslugfield:

```bash
    $ pip install django-randomslugfield
```


## Install

To enable `randomslugfield` in your project you need to add it to
`INSTALLED_APPS` in your projects `settings.py` file:

```python
    INSTALLED_APPS = (
        ...
        'randomslugfield',
        ...
    )
```


## Usage

Import `RandomSlugField` and use it in your model:

```python
    from django.db import models
    from randomslugfield import RandomSlugField

    class MyModel(models.Model):
        slug = RandomSlugField(length=7)
```

The `length` argument is required.


## Advanced Usage

By default randomslugfield generates its slug using these characters:

`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`

You can optionally exclude lowercase/uppercase/digits/vowels using
`exclude_lower=True`, `exclude_upper=True`, `exclude_digits=True`,
`exclude_vowels=True`.

You cannot exclude all characters.

Example:

```python
    class MyModel(models.Model):
        slug = RandomSlugField(length=7, exclude_lower=True)
```

The total number of unique slugs is determined by `characters^length`.

```
    62^9 = 13,537,086,546,263,552 possible slugs
    62^8 = 218,340,105,584,896 possible slugs
    62^7 = 3,521,614,606,208 possible slugs
    62^6 = 56,800,235,584 possible slugs
    62^5 = 916,132,832 possible slugs
```
