Closed ValentinDevPy closed 1 year ago
Hi, Valentin. First of all, you have not provided code, you are using to create records. It's really hard to guess, what you are doing without it. Can you show it? Secondly, I'd like to know what verions of python, django and django-clickhouse you are using.
P. s. according to your logs, sync process is working well, but no operations have been registered for sync for your ClickHouseTest
model. I guess, that there was some trouble with creation of Test
model records.
Hello, I am creating an entry, both manually through the ORM and through the ModelViewSet, the code is below:
Serializer:
class Meta:
fields = '__all__'
model = Test
ViewSet:
class TestViewSet(viewsets.ModelViewSet):
permission_classes = [AllowAny]
queryset = Test.objects.all()
serializer_class = TestSerializer
Manually creating:
Test.objects.create(first_name='123',visits=1,birthday='2022-12-12')
Python version is 3.10.8 Django==4.1.3 Django-clickhouse==1.2.1 DRF==3.14.0
Modified GitHub Actions tests so they check latest software versions https://github.com/carrotquest/django-clickhouse/pull/48
Looks like there is incompatibility with django 4.0+. I'll have a look
Looks like there is incompatibility with django 4.0+. I'll have a look
I also tried to specify Django v3 and downgraded the respective libraries, it did not help.
Failing in django 4.0+ tests are related to django-pg-returning library. I'll create separate compatibility issue there.
Looks like there is incompatibility with django 4.0+. I'll have a look
I also tried to specify Django v3 and downgraded the respective libraries, it did not help.
It is strange. It looks like registering operations are not called when you call create method. Haven't you redeclared create method inside Manager? Can you show me results of:
from django_clickhouse.models import *
print('Model is instance of ClickHouseSyncModel', isinstance(Test, ClickHouseSyncModel), Test.__mro__)
print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__)
print('QuerySet is instance of ClickHouseSyncQuerySetMixin', isinstance(Test.objects, ClickHouseSyncQuerySetMixin))
No
Looks like there is incompatibility with django 4.0+. I'll have a look
I also tried to specify Django v3 and downgraded the respective libraries, it did not help.
It is strange. It looks like registering operations are not called when you call create method. Haven't you redeclared create method inside Manager? Can you show me results of:
from django_clickhouse.models import * print('Model is instance of ClickHouseSyncModel', isinstance(Test, ClickHouseSyncModel), Test.__mro__) print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__) print('QuerySet is instance of ClickHouseSyncQuerySetMixin', isinstance(Test.objects, ClickHouseSyncQuerySetMixin))
No, I didn't redefine it, I didn't see it in the documentation. Console output below:
In [1]: from django_clickhouse.models import *
In [2]: from src.core.models import Test
In [3]: print('Model is instance of ClickHouseSyncModel', isinstance(Test, ClickHouseSyncModel), Test.__mro__)
Model is instance of ClickHouseSyncModel False (<class 'src.core.models.Test'>, <class 'django_clickhouse.models.ClickHouseSyncModel'>, <class 'django.db.models.base.Model'>, <class 'object'>)
In [4]: print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__)
AttributeError: 'ClickHouseSyncManager' object has no attribute '__mro__'
In [5]: print('QuerySet is instance of ClickHouseSyncQuerySetMixin', isinstance(Test.objects, ClickHouseSyncQuerySetMixin))
QuerySet is instance of ClickHouseSyncQuerySetMixin False
What is the platform you are working on? Do django signals work properly there? Especially post_save and post_delete
Model is instance of ClickHouseSyncModel False (<class 'src.core.models.Test'>, <class 'django_clickhouse.models.ClickHouseSyncModel'>, <class 'django.db.models.base.Model'>, <class 'object'>)
I'm working on a mac with m1 but same behavior on test server with ubuntu and x86. Yeah, django-signals work well on my platform.
create
method registers operation here. I don't see any reasons it would not be called, if signals work fine. Do you have ability to debug, if this handler is called correctly?
P. s. I use this libarary in my production environment, based on django 3.2 on Ubuntu and have no any problems like that. Tests also pass well on django 3.2. So I'm not sure how can I reproduce it myself.
No
Looks like there is incompatibility with django 4.0+. I'll have a look
I also tried to specify Django v3 and downgraded the respective libraries, it did not help.
It is strange. It looks like registering operations are not called when you call create method. Haven't you redeclared create method inside Manager? Can you show me results of:
from django_clickhouse.models import * print('Model is instance of ClickHouseSyncModel', isinstance(Test, ClickHouseSyncModel), Test.__mro__) print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__) print('QuerySet is instance of ClickHouseSyncQuerySetMixin', isinstance(Test.objects, ClickHouseSyncQuerySetMixin))
No, I didn't redefine it, I didn't see it in the documentation. Console output below:
In [1]: from django_clickhouse.models import * In [2]: from src.core.models import Test In [3]: print('Model is instance of ClickHouseSyncModel', isinstance(Test, ClickHouseSyncModel), Test.__mro__) Model is instance of ClickHouseSyncModel False (<class 'src.core.models.Test'>, <class 'django_clickhouse.models.ClickHouseSyncModel'>, <class 'django.db.models.base.Model'>, <class 'object'>) In [4]: print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[4], line 1 ----> 1 print('Manager is instance of ClickHouseSyncManager', isinstance(Test.objects, ClickHouseSyncManager), Test.objects.__mro__) AttributeError: 'ClickHouseSyncManager' object has no attribute '__mro__' In [5]: print('QuerySet is instance of ClickHouseSyncQuerySetMixin', isinstance(Test.objects, ClickHouseSyncQuerySetMixin)) QuerySet is instance of ClickHouseSyncQuerySetMixin False
These commands were executed on django3.
I've written them without testing.
First one is my fault, there should be isinstance(Test(), ClickHouseSyncModel)
. But I see from MRO that it will return True
.
Second is strange for me, but the error sais that manager is 'ClickHouseSyncManager' object
This is the thing I wanted to check. So it's ok.
Third is False, because objects is a manager, not QuerySet. Also myh fault
create
method registers operation here. I don't see any reasons it would not be called, if signals work fine. Do you have ability to debug, if this handler is called correctly? P. s. I use this libarary in my production environment, based on django 3.2 on Ubuntu and have no any problems like that. Tests also pass well on django 3.2. So I'm not sure how can I reproduce it myself.
Could you suggest how can I check this?
post_save
has been emitted. If not you can debug all create procedure in order to understand why it has not been called.
Hello, I am using your library, and when creating records in a table there is no data synchronization . In this case, the task queue works correctly, but the tasks themselves do not receive arguments. At the same time, requests to clickhouse through the orm work fine. My docker-compose:
My settings.py:
My Django-model:
My Clickhouse-model:
Logs: