def parseMakeSql(): from django.db import connection, transaction cursor = connection.cursor() cursor.execute("SELECT DISTINCT make FROM web_carclassified") makes = cursor.fetchall() for make in makes: _make = Make() _make.make = str(make[0]) cursor.execute("SELECT count(*) FROM web_carclassified WHERE make = '" + str(make[0]) + "'") _make.count = int(cursor.fetchone()[0]) _make.save()
def parseMakeModel(): makes = CarClassified.objects.all() makes = uniquify(makes) for _make in makes: make = Make() make.make = _make.make make.count = len(CarClassified.objects.all().filter(make=_make.make)) make.save() models = CarClassified.objects.all().filter(make=_make.make) models = uniquify(models) for _model in models: model = Model() model.model = _model.model model.make = make model.count = len(CarClassified.objects.all().filter(model=model.model)) model.save()