use urljoin to create fallback country data URL (#50585)
This commit is contained in:
parent
828075ae23
commit
22de4ad1f1
|
@ -16,6 +16,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -112,7 +113,7 @@ class CountryWidget(forms.Select):
|
||||||
country_url = settings.IMIO_COUNTRY_URL
|
country_url = settings.IMIO_COUNTRY_URL
|
||||||
else:
|
else:
|
||||||
passerelle_url = list(settings.KNOWN_SERVICES['passerelle'].values())[0]['url']
|
passerelle_url = list(settings.KNOWN_SERVICES['passerelle'].values())[0]['url']
|
||||||
country_url = '%s/csvdatasource/pays/data' % passerelle_url
|
country_url = urljoin(passerelle_url, '/csvdatasource/pays/data')
|
||||||
try:
|
try:
|
||||||
self.choices = [(x['id'], x['text']) for x in requests.get(country_url).json()['data']]
|
self.choices = [(x['id'], x['text']) for x in requests.get(country_url).json()['data']]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
Loading…
Reference in New Issue