Skip to content
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

Adding slug convert option #572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hwshim0810
Copy link

Unidecode translates non-English words, I have added an option to use the original language as a slug.

I tried to add a test, but adding non-English characters to the test code seemed to be a problem.

@codecov-io
Copy link

codecov-io commented Dec 10, 2018

Codecov Report

Merging #572 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #572   +/-   ##
=====================================
  Coverage      94%    94%           
=====================================
  Files           4      4           
  Lines         434    434           
  Branches       77     77           
=====================================
  Hits          408    408           
  Misses         16     16           
  Partials       10     10

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e347b6...ecc28bf. Read the comment docs.

@jdufresne
Copy link
Member

I tried to add a test, but adding non-English characters to the test code seemed to be a problem.

Can you clarify? It should not be. We should add a test to verify the behavior before merging.

Copy link
Contributor

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please rebase?

@AnasBuhayh AnasBuhayh mentioned this pull request Sep 30, 2021
@lucemia
Copy link

lucemia commented Apr 21, 2022

+1 for this PR.

Without this PR, django-taggit has serious performance issue in any non-English applications.

i = 1
while True:
slug = self.slugify(self.name, i)
if slug not in slugs:
self.slug = slug
# We purposely ignore concurrency issues here for now.
# (That is, till we found a nice solution...)
return super().save(*args, **kwargs)
i += 1
else:
return super().save(*args, **kwargs)

Insert a new non-English tag to existing 10,000 tags, will cost 10,000 query.

@rtpg
Copy link
Contributor

rtpg commented Apr 21, 2022

@lucemia thank you for pointing this out, I hadn't quite absorbed this fact when this had come up.

To be honest I don't quite know what the value of "ascii-fying" everything for slugs is, it does feel a bit silly. So I think that having this setting, and having it be the new default (rationale: if you're using characters outside of ascii, it's very likely you find that important for your language).

@rtpg
Copy link
Contributor

rtpg commented Apr 21, 2022

Of course after thinking about this a bit more I am reminded that slugification exists primarily for URLs and the like.

For example if you have a URL scheme like /posts/<tag>/ then you want the tag to... at least not contain slashes I suppose.

I am going to try and dig up some ideas here for how to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants