How to sort Django admin list column by a value from a related model
Here's the real-life case. On this blog, I have two models: Post and PostStats. The former is, as you might have guessed, for posts, while the latter is for per post statistics like a view count.Here's...
View ArticleBrief reflections on programming languages I have worked with during my career
I've played and worked with multiple programming languages over my 15-year long career in development (and a bit before, when I studied at school and university). Every language I touched left a piece...
View ArticleIntroducing Django ClearCache 🤠🧹💰 - allows to clear cache via admin UI or...
I've been working with the Django cache recently. And while Django has exceptional caching capabilities, I was surprised to find out that it doesn't provide a simple way to manually clear a cache.I...
View ArticleHow to make Django request.is_ajax() work with JS fetch()
Django's request object has a nifty little method is_ajax. It allows determining whether a request comes from a JS framework (aka old-school ajax). While it works fine with some JS libraries, including...
View ArticleFixing anymail/mailgun "Domain not found" error
Are you swearing at mailgun now? Have you smashed your keyboard already? Do you keep receiving the Domain not found: domainname.com error although you're 100% sure you've set everything up...
View ArticleHow to sort Django admin list column by a value from a related model
Here's the real-life case. On this blog, I have two models: Post and PostStats. The former is, as you might have guessed, for posts, while the latter is for per post statistics like a view count.Here's...
View ArticleBrief reflections on programming languages I have worked with during my career
I've played and worked with multiple programming languages over my 15-year long career in development (and a bit before, when I studied at school and university). Every language I touched left a piece...
View ArticleIntroducing Django ClearCache 🤠🧹💰 - allows to clear cache via admin UI or...
I've been working with the Django cache recently. And while Django has exceptional caching capabilities, I was surprised to find out that it doesn't provide a simple way to manually clear a cache.I...
View ArticleHow to make Django request.is_ajax() work with JS fetch()
Django's request object has a nifty little method is_ajax. It allows determining whether a request comes from a JS framework (aka old-school ajax). While it works fine with some JS libraries, including...
View ArticleFixing anymail/mailgun "Domain not found" error
Are you swearing at mailgun now? Have you smashed your keyboard already? Do you keep receiving the Domain not found: domainname.com error although you're 100% sure you've set everything up...
View ArticleTesting emails in Django
Sending email messages from a web app often seems like throwing stones into a black hole. You create a message, pass it to a mail send function and hope for the best. You don't control an inbox and...
View ArticleDjango + Tailwind CSS = ❤️
If you use Tailwind CSS and want to integrate it easily with Django, check out a package I created about a month ago.Surprisingly it's called Django-Tailwind. You can find it here on GitHub:...
View ArticleAdding custom filters to Django admin is easy!
I'm building a backend for a scraping tool that has two simple models Website and Page, where Website can have many pages.In a simplified form it looks...
View ArticleMake Django's collectstatic command forgiving
Have this ever happened to you? You run a python manage.py collecstatic command, it progresses for some time and then throws an error, something like:ValueError: The file...
View ArticleHow To Prevent Users From Creating Certain Page Types in Wagtail CMS
Sometimes in Wagtail, we have pages that should only have a single instance in the system. Let's say we have a blog that has an index page driven by BlogIndexPage model. We create it once and want to...
View ArticleDjango Filters Problem: How To Display All Results When The Filter Is Not Set
If a view extends django-filter'sFilterView it may look similar to...
View ArticleOverriding Field Widgets In Django Doesn't Work. Template Not Found. The...
One day you may want to override a default Django form input widget. Let's say; you'll want to tweak a Date widget, so it has type="date" on it.So you'd go out and do the regular drill:1) Find the...
View ArticleHow to Hide And Auto-populate Title Field of a Page in Wagtail CMS
Givenfromdjango.dbimportmodelsfromwagtail.wagtailsnippets.modelsimportregister_snippetclassCountryPage(Page):country=models.ForeignKey('wagtail_simple_countries.Country',blank=False,null=True,on_delete...
View ArticleAutomatic Created and Updated DateTime Fields for Django Models
I'm leaving this to my future self, as I keep forgetting it over and over again.If you want to add "create" and "update" time logging to your model, it's as simple...
View ArticleAccessing Model's/Object's Verbose Name in Django Template
Let's say you have a model:fromdjango.dbimportmodelsclassSnippet(models.Model):....classMeta:verbose_name='Snippet'verbose_name_plural='Snippets'And you want to print model's verbose name in a Django...
View Article