Open brianporeilly opened 1 year ago
I can work on this in theory, but I wanted to open it as an issue to discuss best practices before starting anything.
That's by design on Django's side -- https://docs.djangoproject.com/en/4.1/ref/models/querysets/#bulk-create. It bypasses .save() because it's slow af; the best option here would be to prepopulate those fields before passing them into bulkcreate. Your IDE may complain; if you haven't found them yet, all of the searchable* fields are created / added to the model at runtime over here. https://github.com/AlexandriaILS/Alexandria/blob/master/alexandria/searchablefields/apps.py The whole concept flies in the face of best practices, but it's a clean-ish solution that works (as long as .save()
isn't getting bypassed).
Yeah, I agree it's preferred to not mess with the actual code hwre. More just an issue with the seed script, it's not obvious why search doesn't work if you use it to seed your local dev env.
It probably wouldn't be too much of a timesink to just call for obj in Record.objects.all(): obj.save()
. Worth testing.
That's basically what I did after the seed script ran to get things working. It didn't take very long.
When using
bootstrap_dev_site
, thebulk_create()
method is used when generating Patrons and Items. This means thatsave()
is not called, and therefore the searchable_ fields (likesearchable_title
andsearchable_legal_first_name
) are not populated.