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

The conflict between django-cities-light and django-modeltranslation #97

Closed
egregors opened this issue Aug 21, 2015 · 2 comments
Closed

Comments

@egregors
Copy link

Hi. I found the strange behavior of django-cities-light and django-modeltranslation when they are installed together.

If I try to make cities_light --force-import-all an error occurs:

manage.py@laowaiboard > cities_light --force-import-all
bash -cl "/Users/vadim/Documents/Bitbucket/laowaiboard/env/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py cities_light --force-import-all /Users/vadim/Documents/Bitbucket/laowaiboard"
INFO Downloading http://download.geonames.org/export/dump/countryInfo.txt into /Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/cities_light/data/countryInfo.txt
INFO Importing countryInfo.txt
/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/autoslug/utils.py:31: RuntimeWarning: Argument <type 'str'> is not an unicode object. Passing an encoded string will likely have unexpected results.
  return django_slugify(unidecode(value))

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py", line 41, in <module>
    run_module(manage_file, None, '__main__', True)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/cities_light/management/commands/cities_light.py", line 167, in handle
    self.country_import(items)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/cities_light/management/commands/cities_light.py", line 254, in country_import
    self.save(country)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/cities_light/management/commands/cities_light.py", line 501, in save
    model.save()
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/db/models/base.py", line 734, in save
    force_update=force_update, update_fields=update_fields)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/db/models/base.py", line 771, in save_base
    update_fields=update_fields, raw=raw, using=using)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 201, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/Users/vadim/Documents/Bitbucket/laowaiboard/env/lib/python2.7/site-packages/autoslug/fields.py", line 304, in modeltranslation_update_slugs
    populate_from_value = getattr(instance, populate_from_localized)
AttributeError: 'Country' object has no attribute 'name_ascii_en'

Process finished with exit code 1

But If you comment out the line «modeltranslation» in INSTALLED_APPS, cities_light --force-import-all works as well.

@armicron
Copy link

The problem is here
django_autoslug assumes that if you have modeltranslation in INSTALLED_APPS then you registered Country model for translation

Also, I found your workaround link
I added issue

@egregors
Copy link
Author

Thank you. I fixed it, like you suggested.

@jpic jpic closed this as completed Dec 13, 2015
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

No branches or pull requests

3 participants