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
12
votes
3 answers

django countries encoding is not giving correct name

I am using django_countries module for countries list, the problem is there are couple of countries with special characters like 'Åland Islands' and 'Saint Barthélemy'. I am calling this method to get the country name: country_label =…
Maverick
  • 2,738
  • 24
  • 91
  • 157
9
votes
3 answers

django countries currency code

I am using django_countries to show the countries list. Now, I have a requirement where I need to show currency according to country. Norway - NOK, Europe & Afrika (besides UK) - EUR, UK - GBP, AMERICAS & ASIA - USDs. Could this be achieved through…
Maverick
  • 2,738
  • 24
  • 91
  • 157
7
votes
1 answer

How to properly serialize a CountryFIeld from django_countries on Django Rest Framework?

I am trying to get the a CountryField (django-countries package) serialized, but my JSON does not show all the available countries. I read here django_countries in django rest framework on what the possible solution is but I'm not getting the…
6
votes
2 answers

How to add capital to django-cities-light country model?

I'm using django-cities-light (lighter version of django-cities) with Django 1.8.x. It defines the abstract models of Country, Region/State and City, so that we can extend and add custom fields. For example, we can add timezone to city by writing a…
Babu
  • 2,548
  • 3
  • 30
  • 47
5
votes
3 answers

how to have "city" fields depending on "country" field in Django models, without creating their tables

I know there are several questions asked like this (such as this one), but non of them could help me with my problem. I wanna have a City and a Country field in my models, which the City choices is depended on Country; BUT I do not want to define…
Far
  • 420
  • 5
  • 14
4
votes
2 answers

ValueError: Related model cannot be resolved in Django

I'm using Django 2.x. I have a model user_setting which have foreign Key to Country model which was created under address module. Now, I'm using djanog-countries-plus to add Country data and thus have changed user_setting module to now point to…
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
3
votes
1 answer

How to serialize a CountryField from django-countries?

I'm trying to add the CountryField to a serializer for the Register process (using dj-rest-auth) and can't find the correct way to implement it. All the answers I found just say to use what the documentation says, but that doesn't help for me, maybe…
3
votes
1 answer

django_countries in django rest framework

I am trying to create an API which can return all the countries using django_countries. I am trying something following but it is not working. As an individual field, it works fine but with complete countries list it is giving an error. from…
Mark Waugh
  • 423
  • 1
  • 5
  • 10
3
votes
1 answer

How to use django countries in registration form?

I am trying to add django-countries in a registration form that will be used with django-allauth. As per instructions https://github.com/SmileyChris/django-countries I created a model class UserProfile(models.Model): # Other things country…
voger
  • 666
  • 6
  • 22
2
votes
1 answer

Error running WSGI application, ModuleNotFoundError: No module named 'django_countries'

I'm trying to deploy my webApp on PythonAnywhere but the following error occour: 2019-10-01 18:20:12,820: Error running WSGI application 2019-10-01 18:20:12,928: ModuleNotFoundError: No module named 'django_countries' 2019-10-01 18:20:12,928: File…
JLeno46
  • 1,186
  • 2
  • 14
  • 29
2
votes
1 answer

How to add a class to the Django countries widget

Hi I am trying to use a Django plugin called django-countries to add a select with all the countries, sofar It's working but how can I add a html class to the select?
2
votes
1 answer

Django admin: Filter by country. Show only non-empty countries?

I have django model like this: from django.db import models from django_countries.fields import CountryField class Profile(models.Model): name = models.CharField(max_length=200) country = CountryField() In the admin, I want to filter by…
a06e
  • 18,594
  • 33
  • 93
  • 169
2
votes
1 answer

Django countries not show country list

I have problem in Django countries. I install it (over pip), run makemigrations, run migrate, and added on my settings.py django-countries in INSTALLED_APPS In model file i have: from django_countries.fields import CountryField class…
moveax3
  • 336
  • 1
  • 3
  • 10
2
votes
2 answers

Django countries order by translated name

I started using django_countries and added a field to one of my models country = CountryField(blank=True) The problem is the users language is spanish and when the form shows the list of countries they are correctly translated, but they ordered by…
steven2308
  • 2,250
  • 1
  • 19
  • 22
2
votes
2 answers

Django-countries: How to translate?

I have installed django countries today. It works pretty neat. The documentation is unfortunately a bit thin, it says: COUNTRIES A tuple of two part tuples, each consisting of a country code and the corresponding nicely titled (and…
Houman
  • 64,245
  • 87
  • 278
  • 460
1
2 3