[英]Django Cities import error
I can't get to import data with manage.py cities --import=all
, I don't have idea of why this is happening. 我无法使用
manage.py cities --import=all
导入数据,我不知道为什么会这样。 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): 这些是城市设置(我安装了Postgis):
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. 奇怪的是,我在一个新的新项目中安装了django-city,它确实起作用了。 Do you know how to fix this?
你知道如何解决这个问题吗?
You should use filenames
instead of filename
when you provide a list of files: 提供文件列表时,应使用
filenames
而不是filename
:
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 https://github.com/coderholic/django-cities的“配置”部分中的更多详细信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.