Closed browniebroke closed 3 years ago
Thank you @browniebroke for taking the time to write up this proposal.
I'm not a Django expert but from what I understand, proxy class should be reindexed automatically if the underlying model is modified. So I'm not really in favor of passing a new arg or option, your solution 3 seems to be the best but I'm not sure I understand the details.
@clemfromspace What do you think?
Hi @browniebroke and sorry for the late answer,
The third option (Infer it automatically using WebsiteProxy._meta.proxy and WebsiteProxy._meta.concrete_model) looks like the best to me.
Happy to review your PR / help on this :)
Hi @browniebroke Thank you very much for this code submission. I've implemented your logic in one of my projects and I'm afraid to say that it is not working. I updated the model and it did not sync as expected. I'm not sure what exactly is the problem here. Can you guide me through?
I'm afraid I stalled a bit on the pull request, unfortunately. I hit some blocks, and it might be more complicated than I initially thought. The third option doesn't seem doable after all.
It would be a huge help if I could get the CI to run @clemfromspace @julienbourdeau, I cannot get the tests to run locally and not having any sort of feedback is like coding blindfolded.
Same problem here, but I'm not sure what to call from the original model's save and delete signals?
AlgoliaEngine.__post_save_receiver(instance) ?
Is there anyone who can help me fix this or at least give a hint? Any help is appreciated.
closing stalled issue. Feel free to reopen if you want to further discuss the matter.
Description
We started using
algoliasearch-django
recently and we had to compute some fields to be indexed. In our case, the current solution to pre-process fields wasn't suitable as there is a conflict in field names. The model to index already had method/property used in our Django app, and we wanted the same field in Algolia, in a different format.To implement this, we used a proxy model that we register to our index.
This works pretty well, except for the auto-indexing. Algolia connects the signal receivers to listen for changes on our proxy model, but they never get fired, they are fired through on the base model.
This means we have to do this registration ourselves, which isn't a big deal, but I think this library could benefit from this feature.
Steps To Reproduce
Create a proxy model. This is inspired from the test suite, assuming
UnregisteredWebsite
is a model similar toWebsite
:Register it with Algolia:
Calling
save()
ordelete()
on instances ofUnregisteredWebsite
do not trigger the auto-indexing behaviour.Possible solutions I've thought of
auto_index_model=None
algolia_auto_index_model
WebsiteProxy._meta.proxy
andWebsiteProxy._meta.concrete_model
If one of the above is acceptable, I can try to put together a pull request.
Versions