Reputation: 385
I can't get to import data with manage.py cities --import=all
, I don't have idea of why this is happening. Here is the log:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/django/utils/decorators.py", line 184, in inner
return func(*args, **kwargs)
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 86, in handle
func()
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 312, in import_city
uptodate = self.download_once('city')
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 159, in download_once
self.download_cache[filekey] = self.download(filekey, i)
File "/home/julian/.virtualenvs/duenio/local/lib/python2.7/site-packages/cities/management/commands/cities.py", line 119, in download
filepath = os.path.join(self.data_dir, filename)
File "/home/julian/.virtualenvs/duenio/lib/python2.7/posixpath.py", line 75, in join
if b.startswith('/'):
AttributeError: 'list' object has no attribute 'startswith'
These are the cities settings (I have Postgis installed):
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
...
CITIES_FILES = {
'city': {
'filename': ['CO.zip',],
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
}
The weird part is, I installed django-cities in a new fresh project, and it did work. Do you know how to fix this?
Upvotes: 0
Views: 371
Reputation: 6933
You should use filenames
instead of filename
when you provide a list of files:
CITIES_FILES = {
'city': {
'filenames': ['CO.zip',],
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
}
or alternatively:
CITIES_FILES = {
'city': {
'filename': 'CO.zip',
'urls': ['http://download.geonames.org/export/dump/'+'{filename}']
},
}
More details in the Configuration section at https://github.com/coderholic/django-cities
Upvotes: 1