@bmispelon@mastodon.social
@bmispelon@mastodon.social avatar

bmispelon

@bmispelon@mastodon.social

💩🔥💻

This profile is from a federated server and may be incomplete. Browse more on the original instance.

bmispelon, to random
@bmispelon@mastodon.social avatar

I'm really enjoying this post by @capjamesg about fun things you can do on your personal website: https://jamesg.blog/2024/02/19/personal-website-ideas/

After many years of thinking about it, I finally created my own site 2 months ago and it's been a lot of fun. I'd definitely recommend it!

bmispelon,
@bmispelon@mastodon.social avatar

@adamchainz Aww, thanks! 😊

josh, to random
@josh@joshthomas.dev avatar

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.

bmispelon,
@bmispelon@mastodon.social avatar

@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)

bmispelon, to random
@bmispelon@mastodon.social avatar

@djangonews thanks for the two links this week, I'm honored 😁

bmispelon, to random
@bmispelon@mastodon.social avatar

deleted_by_author

  • Loading...
  • bmispelon,
    @bmispelon@mastodon.social avatar

    @webology @djangonews I don't think I'd be able to cope either, that sounds like a lot of work

    bmispelon,
    @bmispelon@mastodon.social avatar
    kfh, to django
    @kfh@chaos.social avatar

    You're a good framework, , but sometimes, SOMETIMES, I'm almost losing it.

    bmispelon,
    @bmispelon@mastodon.social avatar

    @kfh not sure if you wanted a reply, or just to rant.

    In case it was option 2, feel free to ignore this message 😁

    If it was option 1, then superuser doesn't imply staff, the two are independent.

    Superuser is about the permission system : user.has_perm(...) will always be True for a superuser.

    bmispelon,
    @bmispelon@mastodon.social avatar

    @kfh Ah yes, that would do it 😁

    marta, to random
    @marta@oslo.town avatar

    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.

    https://thatmarta.wordpress.com/2024/05/10/on-language-and-boxing-up-a-rant/

    bmispelon,
    @bmispelon@mastodon.social avatar

    @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 🇫🇷

    bmispelon,
    @bmispelon@mastodon.social avatar

    @marta Full agreed!

    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 🙃

    treyhunner, to python
    @treyhunner@mastodon.social avatar

    What are your favorite one liners?

    bmispelon,
    @bmispelon@mastodon.social avatar

    @treyhunner One I came up with today:

    print("".join(chr(127397 + ord(c.upper())) for c in country_code)) # where country_code is a 2-letter country code string, like FR, NO or US

    bmispelon, to django
    @bmispelon@mastodon.social avatar

    New article on my blog: a ORM technique I found for combining JSONObject and Subquery to build model instances: https://blog.bmispelon.rocks/articles/2024/2024-05-09-django-getting-a-full-model-instance-from-a-subquery.html

    bmispelon,
    @bmispelon@mastodon.social avatar

    @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.

    bmispelon,
    @bmispelon@mastodon.social avatar

    @carlton @lilyf @CodenameTim Possibly, but then you'd lose the ability to defer missing fields.

    bmispelon,
    @bmispelon@mastodon.social avatar

    @carlton @lilyf @CodenameTim It's not yet on github, I'm going to do that later today.

    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()).

    bmispelon,
    @bmispelon@mastodon.social avatar

    @webology Fixed, thanks 👍

    bmispelon,
    @bmispelon@mastodon.social avatar
    bmispelon,
    @bmispelon@mastodon.social avatar

    @josh Thanks, I've put the code on github and decided to try model-bakery for the tests 😁

    https://github.com/bmispelon/django-model-subquery

    bmispelon,
    @bmispelon@mastodon.social avatar

    @carlton Also I tried flit for making the package, after your recommendation from last week 😁

    It was rather pleasant as far as python packaging go

    bmispelon,
    @bmispelon@mastodon.social avatar

    @carlton Ah right, I guess arrays need to be homogenous don't they? It might work by casting everything to a string first, then using the same Field.to_python() trick that I use? https://github.com/bmispelon/django-model-subquery/blob/main/src/modelsubquery/functions.py#L46

    bmispelon,
    @bmispelon@mastodon.social avatar

    @carlton Best of luck!

    I didn't dare going deep into the psycopg depths, but I'm sure there's some cool stuff in there too.

    I'm happy to hear back if you find anything (here or via a PR on the project)

    bmispelon,
    @bmispelon@mastodon.social avatar

    @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)

    Rachell, (edited ) to random
    @Rachell@mastodon.social avatar

    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?

    bmispelon,
    @bmispelon@mastodon.social avatar

    @Rachell Happens to me a lot when I'm tired.

    So I guess my advice is to sleep more? 🙊

    Alternatively, you could teach your wife Spanish 😁

    (sorry for the somewhat useless answers, I'm hoping someone else in the replies will have actual tips that I could also use for myself)

    nanorepublica, to django
    @nanorepublica@indiehackers.social avatar

    📣 A cautionary tail of adding soft delete to Models
    📄 Most of the time you aren't going to need it, but be careful if you do.
    🔗 https://softwarecrafts.co.uk/100-words/day-84
    ,,,-utils,

    bmispelon,
    @bmispelon@mastodon.social avatar

    @nanorepublica another huge annoyance for me is that this kind of soft delete modelling renders field uniqueness completely unusable

    pythonbynight, to random
    @pythonbynight@fosstodon.org avatar

    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. 😅

    https://pythonbynight.com/blog/magnetic-resonance-imaging

    bmispelon,
    @bmispelon@mastodon.social avatar

    @pythonbynight Lovely article, thanks for taking the time to write it!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • tester
  • everett
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • rosin
  • slotface
  • InstantRegret
  • mdbf
  • PowerRangers
  • kavyap
  • tsrsr
  • DreamBathrooms
  • Leos
  • ngwrru68w68
  • hgfsjryuu7
  • cubers
  • GTA5RPClips
  • khanakhh
  • vwfavf
  • ethstaker
  • osvaldo12
  • cisconetworking
  • normalnudes
  • tacticalgear
  • modclub
  • anitta
  • All magazines