# This Python file uses the following encoding: utf-8
# !/usr/bin/env python
import os

import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj_hkcm.settings")
django.setup()

from hkcm.models import DistrictsClassification, HongKongEighteenDistricts

if __name__ == "__main__":
    """
    Purpose : Find all eighteen districts in HK
    Author  : Pharrell.zx
    Date    : 2017 Feb 6 """

    all_objects = DistrictsClassification.objects.all()
    hk_eighteen_dist = []
    counter = 1
    for x in all_objects:
        if counter == 1:
            hk_eighteen_dist.append(x.Districts)
            counter += 1
        else:
            if x.Districts not in hk_eighteen_dist:
                hk_eighteen_dist.append(x.Districts)
                counter += 1
            else:
                pass

    id_now = 0
    for x in hk_eighteen_dist:
        id_now += 1
        record = HongKongEighteenDistricts(id=id_now,
                                           Districts=x)

        record.save()
