From 42f823d3a535a7f61a8669c1645ec24aba8a5f45 Mon Sep 17 00:00:00 2001 From: M1ha Date: Wed, 23 Jan 2019 15:51:35 +0500 Subject: [PATCH] Fixed a bug in many_init --- src/django_clickhouse/clickhouse_models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/django_clickhouse/clickhouse_models.py b/src/django_clickhouse/clickhouse_models.py index 9694d16..e964923 100644 --- a/src/django_clickhouse/clickhouse_models.py +++ b/src/django_clickhouse/clickhouse_models.py @@ -6,6 +6,7 @@ from collections import defaultdict from itertools import chain from typing import List, Tuple, Iterable, Set, Any, Dict +import pytz from django.db.models import Model as DjangoModel, QuerySet as DjangoQuerySet from infi.clickhouse_orm.database import Database from infi.clickhouse_orm.engines import CollapsingMergeTree @@ -81,6 +82,12 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)): item = cls(__multi_init=True) item.__dict__.update(cls._defaults) + + for name in kwargs: + field = cls._fields[name] + kwargs[name] = field.to_python(kwargs[name], pytz.utc) + field.validate(kwargs[name]) + item.__dict__.update(kwargs) result.append(item)