Skip to content

Commit 39ac457

Browse files
Update README and settings.py to address common issues and improve lo… (#306)
* Update README and settings.py to address common issues and improve localization support - Added a section in README for common issues related to index row size in PostgreSQL, including solutions for disabling indexing and limiting translation languages. * Enhance README with additional guidance on managing city and country imports - Added new sections to the README detailing how to limit imported countries and cities in settings.py. - Included instructions for excluding specific city and region types to optimize data imports. - Expanded the common issues section to address index size errors and provide relevant solutions.
1 parent 9f761fd commit 39ac457

1 file changed

Lines changed: 43 additions & 7 deletions

File tree

README.rst

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,49 @@ Consult the help with::
110110

111111
./manage.py help cities_light_fixtures
112112

113+
114+
Common issues
115+
--------------
116+
117+
Search names index size issue
118+
------------------------------
119+
120+
If you get the following error::
121+
122+
django.db.utils.OperationalError: index row size 2848 exceeds btree version 4 maximum 2704 for index "cities_light_city_search_names_fb77fed2"
123+
DETAIL: Index row references tuple (1314,1) in relation "cities_light_city".
124+
HINT: Values larger than 1/3 of a buffer page cannot be indexed.
125+
Consider a function index of an MD5 hash of the value, or use full text indexing.
126+
127+
You can fix it by adding the following to your settings.py, this will disable the indexing of the search_names field::
128+
129+
CITIES_LIGHT_INDEX_SEARCH_NAMES = False
130+
131+
Another option is limiting the languages for example to only English and abbreviation, this will fix the issue::
132+
133+
CITIES_LIGHT_TRANSLATION_LANGUAGES = [ 'en', 'abbr']
134+
135+
You want to import only the countries you need, for example France, Belgium and Netherlands, you can do it by adding the following to your settings.py::
136+
137+
CITIES_LIGHT_INCLUDE_COUNTRIES = ['FR', 'BE', 'NL']
138+
139+
You want to import only the cities you need, for example Paris, Brussels and Amsterdam, you can do it by adding the following to your settings.py::
140+
141+
CITIES_LIGHT_INCLUDE_CITY_TYPES = ['PPL', 'PPLA', 'PPLA2', 'PPLA3', 'PPLA4', 'PPLC', 'PPLF', 'PPLG', 'PPLL', 'PPLR', 'PPLS', 'STLMT',]
142+
143+
You don't want to import the cities and regions and subregions, you can do it by adding the following to your settings.py::
144+
145+
CITIES_LIGHT_INCLUDE_CITY_TYPES = []
146+
CITIES_LIGHT_INCLUDE_REGION_TYPES = []
147+
CITIES_LIGHT_INCLUDE_SUBREGION_TYPES = []
148+
149+
Or you can set the sources to empty list:
150+
151+
CITIES_LIGHT_REGION_SOURCES = []
152+
CITIES_LIGHT_SUBREGION_SOURCES = []
153+
CITIES_LIGHT_CITY_SOURCES = []
154+
155+
113156
Development
114157
-----------
115158

@@ -166,13 +209,6 @@ To run it even faster, you can switch to specific tox virtualenv::
166209
CI=true test_project/manage.py test cities_light.tests.test_form.FormTestCase.testCountryFormNameAndContinentAlone
167210

168211

169-
If you want to generate the translations, use the following steps::
170-
171-
source .tox/dev/bin/activate
172-
cd src/cities_light
173-
python manage.py makemessages -l fr
174-
python manage.py compilemessages
175-
176212
If you want to build the docs, use the following steps::
177213

178214
source .tox/dev/bin/activate

0 commit comments

Comments
 (0)