Questions tagged [django-countries]

django-countries is a pluggable Django app which provides country choices for use with forms, and a country field for models

django-countries is a pluggable Django app which provides country choices for use with forms, and a country field for models.

43 questions
1
vote
1 answer

How do you implement the "COUNTRIES_ONLY" setting in django_countries?

I'm new to Django and have a model that takes in user address details. I'm using a CourtryField and only want to display four country options in the form on the user profile template. I believe that I can do this using "COUNTRIES_ONLY" but am not…
Daithí
  • 13
  • 3
1
vote
0 answers

Django CountrySelectWidget not working when Debug=False

I am using Django Countries and the CountrySelectWidget to show the country flag after the CountryField on my form. This works fine when Debug is set to True and I can see the flag fine. However when Debug is set to False the flag image shows as…
Cameron
  • 35
  • 4
1
vote
1 answer

ModuleNotFoundError: No module named 'django_countries'

I have a docker django project and I want to use django-countries. This is my requirements.txt .... django-countries django-cities This is the INSTALLED_APPS in settings.py file INSTALLED_APPS = [ 'django.contrib.admin', …
Rhonald
  • 363
  • 5
  • 18
1
vote
1 answer

filter queryset based on django countries field

this is my viewset: class PollViewSet(viewsets.ReadOnlyModelViewSet): queryset = Poll.objects.all() serializer_class = PollSerializer() def get_queryset(self): country = self.kwargs.get('pk', None) if country is not…
1
vote
0 answers

Unable to sort queryset by country__name

I'm using django-countries to set a country in my django model: # models.py from django_countries.fields import CountryField class MyModel(models.Model): title = models.CharField(max_length=255, blank=True) country = CountryField() I would…
tombreit
  • 1,199
  • 8
  • 27
1
vote
4 answers

How to return actions and parameters in OPTIONS request with django rest framework

I try to return a list of select options for countries using django-countries and django rest framework. I use JWT_AUTH for the authentication. When I try a options request: curl \ -H "Authentication: JWT…
1
vote
1 answer

Display flags in Django form & templates with Django-countries

I'm using Django-countries and I don't overcome to display country flags beside each country in my Django Form or in any templates. I display well the country list, I set correctly the flags folder in my static folder. But impossible to display…
Essex
  • 6,042
  • 11
  • 67
  • 139
1
vote
1 answer

Django countries adding cities to top of list

Using django-countries which works as expected with django, is it possible to add a list of cities to the top of the countries list, instead of getting all the countries and populating a new country model.
Sam B.
  • 2,703
  • 8
  • 40
  • 78
1
vote
1 answer

Django widgets don't work : Country flags

I'm adding a new library : Django_countries on my Django Project and I get a little problem with my form. I get correctly my countries list inside my form, but I don't display flags with widgets beside each country. I'm using this documentation :…
Essex
  • 6,042
  • 11
  • 67
  • 139
1
vote
0 answers

Can't render django-countries-plus options in form template

For some reason I can't get the list of Countries in django-countries-plus to render in my template. The table is imported fine under Countries Plus > Countries and I've set the models.py up as follows: from countries_plus.models import…
1
vote
3 answers

Django-countries and TastyPie: Get country name

I got a model like this: from django.db import models from django_countries.fields import CountryField class Location(models.Model): company = models.CharField(max_length=64) country = CountryField() def __unicode__(self): …
Hi Hi
  • 366
  • 4
  • 20
1
vote
1 answer

How to get Country Code in django-countries

How can I get country code with this library? I don't want to get for example "CO" for Colombia or "NZ" for New Zealand, I want 57 for Colombia, or 1 for USA, for example.
dfrojas
  • 673
  • 1
  • 13
  • 32
1
vote
1 answer

ImportError: cannot import name CountryField

I already installed Django Countries using pip install django_countries and still I'm getting an error of ImportError: cannot import name CountryField: (simpli)Allens-MacBook-Air:~/Sites/augmify/simpli [master]$ python manage.py syncdb Traceback…
AllenC
  • 2,754
  • 1
  • 41
  • 74
0
votes
0 answers

How to use alpha3 country code in django model CountryField

Let's say I have a form that can be filled out by a user with personal details, such as class PersonForm(ModelFormSansSuffix): class Meta: model=Person fields=["name", "nationality"] nationality = forms.ChoiceField( …
0
votes
0 answers

Change order of countries depending on user language

I have a Django app which django-countries. I would like to alter the order of the countries shown based on the user's language. For example if the user is using French, I will bring France, Belgium, Luxumburg, Switzerland etc to the top, whereas…
HenryM
  • 5,557
  • 7
  • 49
  • 105