mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-24 07:19:36 +02:00
Refactor media and static file paths; update countries JSON download URL to use COUNTRY_REGION_JSON_VERSION
This commit is contained in:
parent
c27bf4baba
commit
de45296dc1
2 changed files with 4 additions and 5 deletions
|
@ -136,8 +136,8 @@ STATIC_ROOT = BASE_DIR / "staticfiles"
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
|
STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||||
|
|
||||||
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
|
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ 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
|
||||||
|
@ -39,9 +38,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_URL}.json')
|
countries_json_path = os.path.join(settings.MEDIA_ROOT, f'countries+regions-{COUNTRY_REGION_JSON_VERSION}.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/{COUNTRY_REGION_JSON_URL}/countries%2Bstates.json')
|
res = requests.get(f'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/{COUNTRY_REGION_JSON_VERSION}/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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue