1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-22 22:39:36 +02:00

Update COUNTRY_REGION_JSON_VERSION to v2.4 and adjust download URL in management command

This commit is contained in:
Sean Morley 2024-11-05 10:41:01 -05:00
parent 87928932c2
commit c27bf4baba
2 changed files with 4 additions and 3 deletions

View file

@ -262,4 +262,4 @@ LOGGING = {
} }
# https://github.com/dr5hn/countries-states-cities-database/tags # https://github.com/dr5hn/countries-states-cities-database/tags
COUNTRY_REGION_JSON_VERSION = 'v2.5' COUNTRY_REGION_JSON_VERSION = 'v2.4'

View file

@ -7,6 +7,7 @@ import json
from django.conf import settings from django.conf import settings
COUNTRY_REGION_JSON_URL = settings.COUNTRY_REGION_JSON_URL
COUNTRY_REGION_JSON_VERSION = settings.COUNTRY_REGION_JSON_VERSION COUNTRY_REGION_JSON_VERSION = settings.COUNTRY_REGION_JSON_VERSION
media_root = settings.MEDIA_ROOT media_root = settings.MEDIA_ROOT
@ -38,9 +39,9 @@ class Command(BaseCommand):
help = 'Imports the world travel data' help = 'Imports the world travel data'
def handle(self, *args, **options): def handle(self, *args, **options):
countries_json_path = os.path.join(settings.MEDIA_ROOT, f'countries+regions-{COUNTRY_REGION_JSON_VERSION}.json') countries_json_path = os.path.join(settings.MEDIA_ROOT, f'countries+regions-{COUNTRY_REGION_JSON_URL}.json')
if not os.path.exists(countries_json_path): if not os.path.exists(countries_json_path):
res = requests.get(f'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/refs/tags/{COUNTRY_REGION_JSON_VERSION}/json/countries%2Bstates.json') res = requests.get(f'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/{COUNTRY_REGION_JSON_URL}/countries%2Bstates.json')
if res.status_code == 200: if res.status_code == 200:
with open(countries_json_path, 'w') as f: with open(countries_json_path, 'w') as f:
f.write(res.text) f.write(res.text)