Closed josterpi closed 2 years ago
Whoops, I'm looking into these failures, and in fact noticed in my own project that it's not working quite as expected.
@laymonage I will attempt to manually implement these changes in my project to ascertain whether they work. I have a Django shell query that isn't working and I'm trying to use the Django shell to debug a production issue... so I'll let you know shortly if this works.
@laymonage
I confirmed this fixed my issue in the shell. I hope that's helpful. For now it helps me as I can continue my production debugging.
Let me know if I can assist further! Thank you for this library and your efforts on it!!!
This is also causing me grief. Can't debug an issue in production. I checked out josterpi's branch locally and it fixed the issue in the python shell at least.
@laymonage what would it take to get this merged and a new release? Anything we can help with?
Wasn't expecting it that quick, thanks a ton!
Yes, thank you! I came up with this pull request when it was causing me grief, but then I got pulled away to other things and haven't had any more time for it.
While it works in production and with runserver, JSONFieldConfig.ready() is getting called after the connection_created signal has been sent while running a management command or a shell. So, extend_features() never gets called.
To solve this, we check to see if the connection is_usable and extend_features immediately if it is. If not, register with the connection_created signal and wait until that is sent.
I wasn't sure if the right place to put this was in the ready() method or in connect_signal_receivers(), so I picked one. I'd be happy to put it somewhere else.