Django: Collectstatic Gets Smarter About Comments

Django's collectstatic command just got a lot smarter with the merge of PR #20828, which fixes how it handles URLs inside CSS and JavaScript comments. This community-driven improvement, led by James Bligh with contributions from Nathan Gaberel, prevents collectstatic from accidentally processing URLs that are commented out in your static files.

Duration: PT3M39S

Episode overview

This episode is a short developer briefing from Django.

It explains recent repository work in plain language.

  • Show: Django
  • Published: 2026-03-05T11:02:25Z
  • Audio duration: PT3M39S

Transcript excerpt

This excerpt keeps the crawler page concise. Listen to the episode or use the RSS feed for the full update.

Hey there, Django developers! Welcome back to another episode of the Django podcast. I'm your host, and wow, do I have some exciting news to share with you today. Grab your favorite beverage because we're diving into a really clever improvement that's going to make your static file handling much more reliable.

So here's the story - you know how Django's collectstatic command processes your CSS and JavaScript files, looking for URLs to update with hashed versions for caching? Well, it turns out it was being a little too enthusiastic. It was also processing URLs that were sitting inside comments, which could cause some…

Enter James Bligh with pull request 20828, and this is such a great example of the Django community working together to solve real-world problems. James tackled issue 21080, building on previous work by contributors like Nathan Gaberel. The solution? Teaching collectstatic to be smart about comments in both CSS and…

What I love about this fix is how thoughtful it is. For CSS files, it now properly ignores URLs inside block comments - you know, those wrapped in the slash-star, star-slash syntax. And for JavaScript, it handles both block comments and those handy…

Now,…

The…

Nearby episodes from Django

  1. Streaming, Signals, and Small Wins
  2. Migration Fixes and Speed Wins
  3. The Developer Experience Revolution
  4. Small Changes, Big Heart - Celebrating Community Care
  5. Security First - Critical Vulnerabilities Patched
  6. Housekeeping Heroes and Hidden Bug Fixes
  7. Admin Interface Polish Day
  8. Accessibility First - Making the Admin Better for Everyone