yourlabs / django-cities-light

A simple app providing three models: Country, Region and City model. Also provided, a command to insert or update data from geonames database dumps. Status: stable.
http://django-cities-light.rtfd.org/
MIT License
336 stars 126 forks source link

Problem with parsing of time data #253

Open Gokujo opened 3 years ago

Gokujo commented 3 years ago

I try to import cities with this command D:\GIT\pmv2> python manage.py cities_light

and I get this error

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "D:\Python\envs\pmv2\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "D:\Python\envs\pmv2\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Python\envs\pmv2\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Python\envs\pmv2\lib\site-packages\django\core\management\base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "D:\Python\envs\pmv2\lib\site-packages\cities_light\management\commands\cities_light.py", line 177, in handle
    geonames = Geonames(url, force=force)
  File "D:\Python\envs\pmv2\lib\site-packages\cities_light\geonames.py", line 24, in __init__
    force=force
  File "D:\Python\envs\pmv2\lib\site-packages\cities_light\geonames.py", line 48, in download
    force=force
  File "D:\Python\envs\pmv2\lib\site-packages\cities_light\downloader.py", line 30, in download
    if not self.needs_downloading(source, destination, force):
  File "D:\Python\envs\pmv2\lib\site-packages\cities_light\downloader.py", line 66, in needs_downloading
    '%a, %d %b %Y %H:%M:%S %Z'  # taking time with second
  File "D:\Python\Python37\Lib\_strptime.py", line 571, in _strptime_time
    tt = _strptime(data_string, format)[0]
  File "D:\Python\Python37\Lib\_strptime.py", line 359, in _strptime
    (data_string, format))
ValueError: time data 'Tue, 15 Jun 2021 00:53:43 GMT' does not match format '%a, %d %b %Y %H:%M:%S %Z'

I am using Django 3.0 and Python 3.7

fulepo commented 3 years ago

Hi, I am having the same issue with Python 3.9 and Django 3.1

andrescollares commented 2 years ago

I managed to run it successfully by setting the locale to "en_US".