-
Notifications
You must be signed in to change notification settings - Fork 372
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
Can not slugify() german umlauts (ÄÖÜ) #162
Comments
I'm just trying to figure out the actual issue here, but...do you get this error with Python 3? So far I've focused on writing tests for the import script. This would be a good candidate for some unit tests. |
If you can find the exact line in the German cities text file from Geonames I'll fix this issue and add the line to the test data to make sure we don't break it again. |
I have this same problem on Python 3.6.2, Django 1.11.2. A lot of cities affected:
|
Related (probably) question. What are the ways to find a city by the "normalized" form? In the cities5000.txt the 3rd column is actually always a somehow normalized form. Is it being imported? City.name as well as English in alt_names are different. Düsseldorf specifically becomes "Duesseldorf", which I believe is not considered a correct spelling (?), but even that is helpful. The rest of the city names I ran into so far would work perfectly with the 3rd column values. Sorry about the necroposting. Should I open another issue for this? |
Answering my own stupid question: it's |
@moorchegue No worries about necroposting or asking your question! 😄 Do you have the issue where Python throws a unicode encoding error as well? |
Nope. I believe with Python 3 unicode issues are a thing of the past. Am I right? ☺ |
@moorchegue I certainly hope so, and I think that's the case since you aren't having issues with Python 3. I'm just not sure if @sowinski's issue still exists with Python 3 or if it's just a Python 2 problem. Sounds like it's just a Python 2 problem. :) |
Works with python3 fine |
Checklist
master
branch of django-cities.Steps to reproduce
Download at least German cities. (Having problems with ÖÜÄ)
City.objects.filter(name="Düsseldorf").first().slugify()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/cities/models.py", line 216, in slugify
return '{}-{}'.format(self.id, unicode_func(self.name))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)
Environment:
django-cities==0.5.0.3
Django==1.10.4
Python 2.7.6
MySql 5.5
Ubuntu trusty 32Bit
Tried to write my own slugify function, but the code is crashing before on line:
#models.py
216: return '{}-{}'.format(self.id, unicode_func(self.name))
Is it possible to define my own get_absolute_url somehow?
The text was updated successfully, but these errors were encountered: