Skip to content

Auto-creation of slugs for non-ASCII users #3741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
candlerb opened this issue Dec 9, 2019 · 2 comments
Closed

Auto-creation of slugs for non-ASCII users #3741

candlerb opened this issue Dec 9, 2019 · 2 comments

Comments

@candlerb
Copy link
Contributor

candlerb commented Dec 9, 2019

Environment

  • Python version: 3.5.2
  • NetBox version: 2.6.7

Proposed Functionality

There are many objects which have a "slug" as well as a name: e.g. Site, Region, Rack Group, Rack Role, Device Roles, Platforms, Manufacturers, etc

Currently, when user creates one of these objects, then as they type a slug is generated from the ASCII parts of the text. Symbols and spaces are replaced with dash; high unicode characters do nothing.

In the limiting case of someone using a non-Roman alphabet, the name they enter will have no slug at all. The form cannot be saved, so they are forced to assign a Roman slug of their own.

Possible solutions:

  1. Allow non-ASCII slugs. Django's slugify function has an allow_unicode option.

    >>> slugify('What does 台灣 mean?', allow_unicode=True)
    'what-does-台灣-mean'
    

    Since slugs are intended for use in URLs, this opens a can of worms about how such slugs are actually used in URLs (percent-encoded UTF-8?)

  2. Auto-generate proposed slugs using a library such as unidecode (Python/AJAX) or entirely in the browser using a native Javascript version.

    This may work better for some languages (e.g. Chinese) than others (e.g. Japanese).

Use Case

Speakers of languages which are not based on the Roman alphabet

Database Changes

None

External Dependencies

Possibly a unidecode library.

@jeremystretch jeremystretch added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Dec 9, 2019
@jeremystretch
Copy link
Member

This was addressed in the fix for #3721.

@jeremystretch jeremystretch removed the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Jan 28, 2020
@candlerb
Copy link
Contributor Author

I don't think this has been fixed as of v2.8.0. To replicate:

  • Devices > Device Roles > +
  • Enter a Device Role consisting of entirely non-ASCII characters
  • Click Create

The creation is blocked:

image

If you mix in some ASCII characters, only the ASCII characters appear in the slug:

image

However, the fix for #3721 now allows general Unicode characters in the slug. Hence the code which generates the slug could be changed to allow everything through (except spaces to dashes)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants