Closed s4ke closed 1 year ago
This concerns Django 3.1 compatibility.
Running into the same issue when trying to add django_multitenant
to project.
Only spent a few minutes with @s4ke's workaround, haven't gotten to work yet.
For clarification, @s4ke, run your workaround in your urls.py (root level? app level? haven't had luck with either location)
@quinceleaf I added it in urls.py
But in the end it varies on your import order. You have to run this as soon as possible so that models are not initialized yet.
@quinceleaf Did u manage to solve this issue? Tried the solution by s4ke but doesnt seem to work for me either.
@s4ke @Keekteng @quinceleaf started working on the issue. However, as a workaraound, you can check this issue https://github.com/citusdata/django-multitenant/issues/138
I added a test which shows this issue does not exist any more. PR that tests this case https://github.com/citusdata/django-multitenant/pull/152
Hey,
With the current version of django-multitenant, we are having problems with using classes with the mixin in migrations. Basically, the issue is that __set_attr__ does not play well with objects that are resolved like this:
The reason for this is that Django resolves the classes one by one and when resolving the TenantModelMixin it calls __set_attr__ differently than in normal mode. Then self.tenant_field somehow triggers a Django reload from database which that then makes everything crash:
To reproduce, you can simply create a migration and try to use the model either via all_objects or via any constructing method (e.g. Model.objects.create).
My workaround for now is to run this code at the top of my urls.py:
This is obviously not the fix for everyone, but i think illustrates the issue rather nicely.