Comments (7)
Odd... django-countries doesn't use any database entries. All that is stored in the db is the ISO code. Retrieving the field uses a descriptor that creates a pretty simple Country object, calling str/unicode just returns the code. Calling .name on it just references against a static dictionary of countries to return the actual name.
Not sure why you'd be seeing a large overhead. To be clear, you're just seeing the country codes displayed as text in that column in the admin list view, correct?
from django-countries.
I'm seeing the country names in that column.
from django-countries.
Are you using the latest version?
from django-countries.
I'm seeing the same problem here. I just upgraded from 2.0b4 to 2.1.2, and the problem persists.
I have an admin page with one CountryField in list_display and list_filter. According to DDT, with 100 rows, it takes about 3000 ms to load. Without the CountryField in list_display and list_filter, it takes about 120 ms.
I've profiled the page and attached a call-graph picture. The branch on the left shows something going on with the iter method (init.py:45) where I end up with a million calls to ugettext.
from django-countries.
Thanks for the profiling work, Christian.
It definitely seems that we need to cache the sorted country list against the language used in the current thread, so all future iterations have it presorted. This would tie in nicely with the work being discussed in #44
from django-countries.
It definitely seems that we need to cache the sorted country list against the language used in the current thread, so all future iterations have it presorted. This would tie in nicely with the work being discussed in #44
It seems to be that both can be done separately, implementing the caching. There is low hanging fruit in the code too, for example Countries.name(..)
performs dict(self.countries).get(code, '')
every time; the list of tuples is converted to a dict to be thrown away a millisecond later. That kind of thing would also improve the performance.
from django-countries.
Optimization has been done, this shouldn't be an issue now.
from django-countries.
Related Issues (20)
- Change country order based on user language
- Short country names HOT 1
- multiple=True widget + limit HOT 1
- Adding Kosovo HOT 5
- Question about validation and or documentation. HOT 1
- Turkey localization key HOT 4
- Feature Request: Filter for countries by continent HOT 1
- Martinique name in Ukraine (uk) localization.
- Uses Deprecated package since Django 3.0(django.utils.six) HOT 1
- DeprecationWarning: pkg_resources is deprecated as an API HOT 1
- Show all flag_css in single html page
- Wrong openapi spec when using country_dict=True
- Support for Python version 3.12 on PyPI HOT 6
- Consider moving to jazzband HOT 3
- Django 5.0 breakage HOT 13
- Ülke adlarını iki dilde görmek / Seeing country names in two languages HOT 2
- When setting `COUNTRIES_OVERRIDE`, allow custom flag_url HOT 1
- multiple = True does not work on serializer_fields.CountryField
- Allow null=True on a models.CountryField with multiple=True
- Countries.__iter__ very slow in Django admin HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-countries.