@adamchainz@fosstodon.org
@adamchainz@fosstodon.org avatar

adamchainz

@adamchainz@fosstodon.org

:django: #Django technical board member
🍕 London Django Meetup Organizer with https://fosstodon.org/@cgl
✍️ Author of three books on Django and Git
🇬🇧 London / 🇵🇹 Lisbon

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

adamchainz, to random
@adamchainz@fosstodon.org avatar

♦️ There is a safer alternative to 'git push --force'!

🫸 Use --force-with-lease and --force-if-includes to restrict force pushes so that they don’t unintentionally overwrite commits pushed by others.

Explained in my post: https://adamj.eu/tech/2023/10/31/git-force-push-safely/

adamchainz,
@adamchainz@fosstodon.org avatar

@zolyguy the best day to learn is yesterday, the second best is today!

jack, to django
@jack@social.jacklinke.com avatar

I finally got around to upgrading my main project from Django 4.2 to Django 5.

I allocated several hours this evening for the arduous process of making sure I got everything right, and before I got started I figured I'd give django-upgrade (by @adamchainz) a try this time around.

No more than 15 minutes later my project was running on Django 5, tested good, and pushed to production.

Wait, what?!?! 😲

Super impressed with how easy django-upgrade made it ❤️

https://pypi.org/project/django-upgrade/

adamchainz,
@adamchainz@fosstodon.org avatar

@jack Great to hear.

Which fixer was the most helpful? There are none for Django 5.0 but maybe the 4.1 or 4.2 ones fixed some deprecations that you hadn’t addressed…

SebastianM6L, to django
@SebastianM6L@mastodon.social avatar

Why isn't

Model.objects.get_or_none()

a thing in ?

That would save some boilerplate code or am I wrong?

Because if there is a chance that there is no entry for the query get()will raise a DoesNotExist exception that you have to catch.

get_or_none()would be cleaner in my opinion.

adamchainz,
@adamchainz@fosstodon.org avatar

@SebastianM6L Many duplicate closed tickets asking about this:

https://duckduckgo.com/?t=ffab&q=site%3Acode.djangoproject.com+get_or_none&ia=web

Also, I’ve seen several packages implement it. I think it could be a worthwhile forum discussion, at laest to gather more opinions. I suggest you start a thread on https://forum.djangoproject.com :)

adamchainz,
@adamchainz@fosstodon.org avatar

@SebastianM6L Yeah it’s hard to dive into such a long-running project. We’re all here to help. Ping me with your forum thread 😀

adamchainz, to django
@adamchainz@fosstodon.org avatar

I’m helping a client upgrade to django-import-export v4, and I gotta say I’m enjoying the clarity of the release notes. Every breaking change spelled out, with PR links. Thank you Matt :)

https://django-import-export.readthedocs.io/en/stable/release_notes.html

adamchainz, to python
@adamchainz@fosstodon.org avatar

Short-term contract shared by one of the folks at Foxley Talent.

https://www.linkedin.com/posts/activity-7197142899942113280-8GNb

adamchainz, to python
@adamchainz@fosstodon.org avatar

✍️ New post with a testing tip for mocking inner imports.

https://adamj.eu/tech/2024/05/17/python-mock-inner-import/

bbelderbos, to github
@bbelderbos@fosstodon.org avatar

🚀 Quickly jump from your local #git repository to its corresponding GitHub page with this handy shell alias! ✨

🔗 Add openrepo to your shell profile or rc file, source it, and now you can simply type openrepo in your terminal to open your GitHub repo. 😎

#GitHub #DevTip

adamchainz,
@adamchainz@fosstodon.org avatar

@bbelderbos GitHub CLI: gh repo view --web

Also has jump to the PR for the current branch: gh pr view --web

danielfeldroy, to random
@danielfeldroy@fosstodon.org avatar

Hello LaTeX, good to see you again.

adamchainz,
@adamchainz@fosstodon.org avatar

@danielfeldroy ✍️✏️🚀

adamchainz, to python
@adamchainz@fosstodon.org avatar

A pattern I’ve recently enjoyed using:

  1. Change some function in a way that needs fixes to call sites.
  2. Run the whole test suite with pytest.
  3. Copy the list of failing test IDs from pytest’s summary into a scratch file.
  4. Fix up the found callers.
  5. Verify everything fixed by saving the list of tests with: pytest $(cat scratch/testids.txt)

adamchainz,
@adamchainz@fosstodon.org avatar

@watte Yes, and allowing partial test runs in step four whilst fixing up certain callers.

Edent, to random
@Edent@mastodon.social avatar

What's the lowest amount you've paid for something using a credit card?

Went to the market the other day and paid for a £2 punnet of fruit using a credit card. Guy was running Square on his phone, showed me the screen, I tapped, done.

I remember when everyone was £10 minimum for card payments, even in large shops. Now sole-traders can take instant payment for low value amounts. Brilliant!

adamchainz,
@adamchainz@fosstodon.org avatar

@Edent I regularly go in Tesco and buy a single banana for my toddler at 27p.

adamchainz,
@adamchainz@fosstodon.org avatar

@OliverC @alexhern @Edent This is a small local supermarket, they’re cheaper in larger ones. I always thought produce was more expensive in the US, I saw broccoli at $5 in a large supermarket, some years ago.

adamchainz,
@adamchainz@fosstodon.org avatar

@Edent @alexhern we are all apes here

circumeo, to django
@circumeo@mastodon.social avatar

Trying to upload a directory and use webkitRelativePath to preserve the local path in a app, and it seems like that might not be so easy.

I've tried a custom upload handler, but even there, Django seems to have already stripped the path.

adamchainz,
@adamchainz@fosstodon.org avatar

@circumeo Did you get any further? Sounds like an interesting feature to support, though we’d probably wait for the cross-browser spec to add it to Django itself.

adamchainz,
@adamchainz@fosstodon.org avatar

@circumeo Ah, looking at the docs, this is an HTML input property, only: https://developer.mozilla.org/en-US/docs/Web/API/File/webkitRelativePath . I think Django isn’t stripping the path, it’s just not sent by the browser. I think you need to use JavaScript to put the values into some form field if you want to send them to the server.

adamchainz,
@adamchainz@fosstodon.org avatar

@circumeo Ah I see. It is probably up in the WSGI later, and may even be a recommended step in HTTP or WSGI servers. Deserves more research.

SebastianM6L, to django
@SebastianM6L@mastodon.social avatar

Any #django cracks here who can explain me why when I run my tests with the django built in manage.py test (runs unittest) I have 51 tests run.

When I run them with pytest It will only run 38 tests.

#python #pytest

adamchainz,
@adamchainz@fosstodon.org avatar
adamchainz, to random
@adamchainz@fosstodon.org avatar

Just blocked a bunch more AI bots in my site’s robots.txt, thanks to this post from @cory:

https://coryd.dev/posts/2024/go-ahead-and-block-ai-web-crawlers/

adamchainz,
@adamchainz@fosstodon.org avatar

@cory A recent post that further convinced me LLMs mostly rehash content from the web: https://lcamtuf.substack.com/p/large-language-models-and-plagiarism

adamchainz,
@adamchainz@fosstodon.org avatar

@cory great!

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!

adamchainz,
@adamchainz@fosstodon.org avatar

@bmispelon Great list, and I’m loving your site 👏

adamchainz, to django
@adamchainz@fosstodon.org avatar

🆙 django-upgrade 1.17.0 is out, with new options to select which fixers run: --only, --skip, and --list-fixers.

🙏 Thanks to Gav O'Connor for the PR, and @davidszotten for initial work.

#Django

https://github.com/adamchainz/django-upgrade

adamchainz, to python
@adamchainz@fosstodon.org avatar

✍️ New post covering a small #Python helper to return all subclasses of a given class.

https://adamj.eu/tech/2024/05/10/python-all-subclasses/

adamchainz,
@adamchainz@fosstodon.org avatar

@anze3db love a good yield from 😇

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • GTA5RPClips
  • rosin
  • Youngstown
  • everett
  • khanakhh
  • slotface
  • InstantRegret
  • Durango
  • ngwrru68w68
  • kavyap
  • modclub
  • DreamBathrooms
  • mdbf
  • JUstTest
  • magazineikmin
  • thenastyranch
  • cubers
  • cisconetworking
  • osvaldo12
  • ethstaker
  • normalnudes
  • Leos
  • tester
  • megavids
  • tacticalgear
  • anitta
  • lostlight
  • All magazines