Skip to content

Commit

Permalink
fix(country-column): fix getting unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Nov 10, 2023
1 parent 1c49180 commit 2f93cf4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fiesta/apps/fiestatables/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db.models import Choices, Model
from django.db.models.fields.files import FieldFile
from django.utils.html import format_html
from django_countries import countries
from django_countries.fields import Country
from django_tables2.columns import BoundColumn

Expand All @@ -21,10 +22,11 @@ class CountryColumn(tables.Column):
attrs = {"td": {"data-flag": str(True).lower()}}

def render(self, value):
c_code = countries.by_name(value)
return format_html(
"<span title='{}'>{}</span>",
value,
Country(value).unicode_flag,
Country(c_code).unicode_flag if c_code else value,
)

def value(self, value):
Expand Down

0 comments on commit 2f93cf4

Please sign in to comment.