Skip to content
Browse files

fixed postal codes primary key problem

  • Loading branch information...
1 parent 4206af8 commit 83bc35006dc86b329cc952793490b8997aef72fd @Qarterd Qarterd committed
Showing with 3 additions and 14 deletions.
  1. +0 −11 cities/management/commands/cities.py
  2. +1 −1 cities/models.py
  3. +2 −2 setup.py
View
11 cities/management/commands/cities.py
@@ -433,12 +433,6 @@ def import_postal_code(self):
self.build_country_index()
self.build_region_index()
-
- self.logger.info("Building postal code index")
- postal_code_index = defaultdict(dict)
- for country in postal_codes:
- for obj in postal_codes[country].objects.all():
- postal_code_index[country][obj.code] = obj
self.logger.info("Importing postal codes")
for line in data:
@@ -459,11 +453,6 @@ def import_postal_code(self):
pc_type = postal_codes[country_code]
pc = pc_type()
-
- # Replace matching postal code in db if any
- try: pc.id = postal_code_index[country_code][code].id
- except: pass
-
pc.country = country
pc.code = code
pc.name = items[2]
View
2 cities/models.py
@@ -188,7 +188,7 @@ def name_full(self):
fields = {
'country': models.ForeignKey(Country,
related_name = 'postal_codes_' + country),
- 'code': models.CharField(max_length=20, db_index=True),
+ 'code': models.CharField(max_length=20, primary_key=True),
'name': models.CharField(max_length=200, db_index=True),
'region_0_name': models.CharField(max_length=100, db_index=True, verbose_name="region 0 name (state)"),
'region_1_name': models.CharField(max_length=100, db_index=True, verbose_name="region 1 name (county)"),
View
4 setup.py
@@ -10,7 +10,7 @@ def read(fname):
setup(
name='django-cities',
- version='0.181',
+ version='0.19',
description='Place models and data for Django apps',
author='Dan Carter (original by Ben Dowling)',
author_email='carterd@gmail.com',
@@ -18,7 +18,7 @@ def read(fname):
packages=find_packages(),
include_package_data=True,
zip_safe=False,
- long_description=read('README'),
+ long_description=read('README.md'),
license = "MIT",
keywords = "django cities countries regions postal codes geonames",
classifiers = [

0 comments on commit 83bc350

Please sign in to comment.
Something went wrong with that request. Please try again.