Wrote a cursed custom Django field, OPField, that stores the location to a 1Password item using their custom URI (op://…) and has the ability to get the secret via the op cli.
op_uri, secret = OPField.with_secret()
I blame @CodenameTim and his blog post about the RegisterField that I haven’t been able to get out of my head since he wrote it months ago.
@josh@CodenameTim in case you're interested, I think you should be able to automatically register the property on the model by defining a contribute_to_class() method on the field class. Then you wouldn't have to use the with_secret() tuple hack (which is quite clever btw)
You speak Norwegian with a Polish accent. Your vowels strained like half-smiles you receive from your neighbors; your consonants rough like a Monday morning workout session at SATS. There’s no escaping from stereotypes your accent invokes.
@marta what a lovely and powerful article, thanks for sharing.
It echoes a lot of my own feelings about my adoptive språk and the impossibility of being an immigrant. Even for someone whose first language enjoys quite a high status here 🇫🇷
Not to mention that the demand for integration is made very selectively. As a white western european immigrant I can't remember ever being asked (or suggested) to integrate I wonder why that is 🙃
@CodenameTim Yes, this technique should work well for the "latest comment in thread" scenario. That might even have been a better example to use 😅
To be honest I was surprised how far I was able to get, I kept thinking I would hit some fundamental limitation of the ORM at some point, but I never did.
I mention the deferring bit at the end of the post. Basically the idea is that if the jsonobject doesn't contain all the model fields, you can still instanciate the model and the missing fields will be deferred (same as if you'd used Django's .defer()/.only()).
@hvdklauw Amazing! I knew that my usage of _meta.get_fields() was a bit optimistic, thanks for getting your hands dirty and doing the legwork on relational fields. Much appreciated ✨
(I'll take a closer look at the code in the next few days)
I was telling my wife, in Korean, about my Spanish class...and I got two sentences in until I realized I had switched to Spanish without realizing. She doesn't know Spanish. 😅 It's funny, we had a good laugh but frustrating as hell.
Brains are weird. 🤪
Does this happen to you? Any tips on context switching and maintaining that switch?
I didn't think I would write over 1800 words about my hurt knee, but here we are.
If you're in the mood for something entirely NOT python related, moody, melancholy, and maybe a little entertaining... check out my latest post at Python By Night. 😅