Closed fzdmd closed 6 years ago
Hi!
As I understand, you are using filenames
with only one key in CITIES_FILES dictionary. I had this problem too and I replaced filenames
with filename
key.
CITIES_FILES = {
# ...
'city': {
'filename': 'US.zip',
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
# ...
}
# ...
'city': {
'filenames': ["US.zip"],
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
# ...
}
It looks like bug.
same here, but i tried with more than one filename in the list:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 160, in handle
func()
File "/usr/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 461, in import_city
self.download('city')
File "/usr/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 177, in download
filename = settings.files[filekey]['filename']
KeyError: 'filename'
I don't think this is a bug, this is intended. However, I may need to document this more.
Relevant code:
if 'filename' in settings.files[filekey]:
filenames = [settings.files[filekey]['filename']]
else:
filenames = settings.files[filekey]['filenames']
If you have only one filename, you should put it in the filename
(singular) key, if you have an iterable of filenames (even if the iterable only has one element), you should put it in the filenames
(plural) key.
If either of those two options is not working for you, then it's a bug. Please give me the versions of Django and django-cities you are using (note: Django 2.0 is not supported yet), the full Python traceback, your complete CITIES
settings, any relevant excerpts from the files you are using, and any and all other relevant troubleshooting information you think I should know. But simply stating "I tried this, here's the error" is a lot less helpful than you might think.
Also, I'm closing this issue because it doesn't contain the information I asked for in the issue template I created for this repo. You even had to delete that template to submit your issue! I put some effort into that and you just disregarded it completely 😢.
Feel free to reopen this issue once you have filled out the issue template at:
https://github.com/coderholic/django-cities/blob/master/ISSUE_TEMPLATE.md
by copying that, pasting it into your issue form:
and filling out all of the necessary information:
(These pictures are just examples from a different repository but the process is the same.)
I actually believe there is a bug. For example, this works fine:
CITIES_FILES = {
'city': {
'filename': "NO.zip",
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
}
Using a single filename. But if using an iterable with 'filenames':
CITIES_FILES = {
'city': {
'filenames': ["SE.zip", "FI.zip", "NO.zip"],
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
}
File "/project/lib/python3.5/site-packages/cities/management/commands/cities.py", line 177, in download
filename = settings.files[filekey]['filename']
KeyError: 'filename'
python manage.py cities --import=city Gives me an error: filename = settings.files[filekey]['filename'] KeyError: 'filename'