Skip to content

Commit

Permalink
Fixed tool to import postal codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Feser committed Oct 24, 2016
1 parent de12f82 commit b2243f8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cities/management/commands/cities.py
Expand Up @@ -16,7 +16,7 @@

import io
import os
import sys
import re
import logging
import zipfile
import time
Expand Down Expand Up @@ -659,7 +659,6 @@ def import_postal_code(self):

# Find country
code = item['postalCode']
country = None
try:
country = self.country_index[country_code]
except:
Expand All @@ -683,14 +682,13 @@ def import_postal_code(self):
if hasattr(PostalCode, 'subregion'):
subreg_name_q |= Q(subregion__code=item['admin2Code'])

if hasattr(PostalCode, 'district'):
dst_name_q |= Q(district__code=item['admin3Code'])

return reg_name_q, subreg_name_q, dst_name_q
# TODO: uncomment after updating District model and management command
# if hasattr(PostalCode, 'district'):
# dst_name_q |= Q(district__code=item['admin3Code'])

try:
if item['longitude'] and item['latitude']:
pa = PostalCode.objects.get(
pc = PostalCode.objects.get(
reg_name_q, subreg_name_q, dst_name_q,
country=country,
code=code,
Expand Down

0 comments on commit b2243f8

Please sign in to comment.