mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-02 11:45:17 +02:00
Redownload when region data version changes
This commit is contained in:
parent
6ac3f0541f
commit
cc7c04b0ec
4 changed files with 32 additions and 3 deletions
|
@ -38,7 +38,7 @@ class Command(BaseCommand):
|
|||
help = 'Imports the world travel data'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
countries_json_path = os.path.join(settings.MEDIA_ROOT, 'countries+regions.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):
|
||||
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:
|
||||
|
|
|
@ -34,7 +34,7 @@ def visits_by_country(request, country_code):
|
|||
return Response(serializer.data)
|
||||
|
||||
class CountryViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
queryset = Country.objects.all()
|
||||
queryset = Country.objects.all().order_by('name')
|
||||
serializer_class = CountrySerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue