Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 544973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:42:43+00:00 2026-05-13T10:42:43+00:00

A site in Vietnamese, it is virtually no different to English. However, there is

  • 0

A site in Vietnamese, it is virtually no different to English. However, there is a problem that is slug. When I type characters such as “ư”, “ơ”, “á”,… Django is not identified. Solution here is to replace characters that do not sign into.
Eg:

ư -> u 
ơ -> o 
á -> a 

One from “những-viên-kẹo” will become “nhung-vien-keo”.
However, I do not know how to do this. Someone help me. Thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:42:44+00:00Added an answer on May 13, 2026 at 10:42 am

    [edit]

    I take it back, django’s django.template.defaultfilters.slugify() does what you want, using unicodedata.normalize and .encode('ascii', 'ignore'). Just feeding your string into slugify will work:

    from django.template.defaultfilters import slugify
    print slugify(u"những-viên-kẹo")
    

    To do this automatically, add this to the .save() method in your models:

    from django.template.defaultfilters import slugify
    MyModel(models.Model):
        title = models.CharField(max_length=255)
        slug  = models.SlugField(blank=True)
    
        def save(self, *args, **kwargs):
            if not self.slug:
                self.slug = slugify(self.title)
            super(MyModel, self).save(*args, **kwargs)
    

    The slolution I wrote ealier (below) would still be useful for languages that require additional characters in their translation, eg German’s ü->ue, ß->ss etc.

    [original post]

    Python allows you to use a translation dict to map characters to a replacement string.

    A simple version for you case would be:

    vietnamese_map = {
        ord(u'ư'): 'u',
        ord(u'ơ'): 'o',
        ord(u'á'): 'a',
        ord(u'n'): 'n',
        ord(u'h'): 'h',
        ord(u'ữ'): 'u',
        ord(u'n'): 'n',
        ord(u'g'): 'g',
        ord(u'v'): 'v',
        ord(u'i'): 'i',
        ord(u'ê'): 'e',
        ord(u'n'): 'n',
        ord(u'k'): 'k',
        ord(u'ẹ'): 'e',
        ord(u'o'): 'o',
    }
    

    And then you can call:

    print u"những-viên-kẹo".translate(vietnamese_map)
    

    To get:

    u"nhung-vien-keo"
    

    For more advanced use (ie a dynamic dict), see eg http://effbot.org/zone/unicode-convert.htm

    Note that the above is just to show you what the map needs to look like, it’s not a particularly convenient way of entering the data. A more convenient way to do the exact same thing is something like:

    _map = u"nn hh ữu nn gg vv ii êe nn kk ẹe oo"
    # Take the above string and generate a translation dict
    vietnamese_map = dict((ord(m[0]), m[1:]) for m in _map.split())
    print u"những-viên-kẹo".translate(vietnamese_map)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Site here . Why is it that the code works for $('#club').change(function(event) but not
My site is here . It used to be a Django-powered blog. However I
My site, which is built on Python/Postgresql with django, has an area where you
i was recently asked why a tumblr theme of mine does not display Vietnamese
My site has the following url format: www.mysite.com/Display.aspx?ID=128 However most users see the url
my site is allow users to register with arabic/english names i am trying to
The site is http://www.kingcharltonmusic.com/album/wednesday-overproof-riddim-2/ I am using a plugin that asks for mp3 and
Site: http://sebastiano.freehostia.com/ CSS: /style.css I'm not overly sure what's going wrong with the positioning
My site is a music site that with 24 single song players on each
My site is almost up and running, but in the original code there are,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.