fix currency
This commit is contained in:
parent
c50cd7c693
commit
924b4e68e9
|
|
@ -3,6 +3,7 @@ import requests
|
|||
from establishment.models import Establishment
|
||||
from main.models import Currency
|
||||
from location.models import Country
|
||||
from django.template.defaultfilters import slugify
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
|
@ -23,15 +24,15 @@ class Command(BaseCommand):
|
|||
if isinstance(country_list, list):
|
||||
currency_dict = country_list[0].get("currencies")[0]
|
||||
if currency_dict:
|
||||
name = currency_dict.get("name")
|
||||
name = currency_dict['name']
|
||||
if name:
|
||||
currency, created = Currency.objects.get_or_create(
|
||||
slug=currency_dict.get("name").lower(),
|
||||
slug = slugify(name)
|
||||
currency, _ = Currency.objects.get_or_create(
|
||||
slug=slug,
|
||||
)
|
||||
if created:
|
||||
currency.name = {"en-GB": name},
|
||||
currency.sign = currency_dict.get("symbol"),
|
||||
currency.save()
|
||||
currency.name = {"en-GB": name},
|
||||
currency.sign = currency_dict["symbol"],
|
||||
currency.save()
|
||||
establishments = Establishment.objects.filter(address__city__country=country)
|
||||
establishments.update(currency=currency)
|
||||
count += 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user