Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Polishing and Usability - Building SaaS #69
In this episode, we polished some parts of the application. Now that my first customer is using the app regularly, the feedback is coming in rapidly. We worked to fix some of the issues that she found. The first issue that I tackled dealt with ambiguity about a course’s relationship to a school year on the course’s detail page. I fixed this issue by displaying the grade level on the course page to provide all the details. -
A Guide to Django Web Development for your Business
It’s frustrating to decide the technology stack for your product – unless you are an experienced CTO. Whether to choose Ruby on Rails or Flask or Django web development or anything else – it’s challenging. Even when you decide on a framework, there are various problems. Trusting the framework for fulfilling your requirements is an […] The post A Guide to Django Web Development for your Business appeared first on BoTree Technologies. -
Async Views in Django 3.1
This post looks at how to get started with Django's new asynchronous views. -
Creating a Low Cost Managed Kubernetes Cluster for Personal Development using Terraform
Kubernetes is an open-source system that's popular amongst developers. It automatically deploys, scales, and manages containerized applications. Yet for those working outside of the traditional startup or corporate setting, Kubernetes can be CPU and memory-intensive, disincentivizing developers from using a strategically beneficial tool. We'll highlight some of the constraints posed by using Kubernetes and offer a series of low-cost, practically-beneficial solution: a Google Kubernetes Engine cluster deployed and managed with Terraform. Want to run Kubernetes locally? [Kind](https://github.com/kubernetes-sigs/kind) is a tool that’s remarkably easy to set up and experiment with. It even supports multi-node clusters! However, the abundance of pods and nodes can be CPU/memory intensive. Another potential roadblock is the popularity of managed Kubernetes solutions: since many companies go this route, you'd want to have some experience with a managed solution. Gaining this experience in a non-corporate setting means personally using Managed Kubernetes –– a costly investment for a solo developer. The baseline cost for an EKS cluster is $72 per month, with similar pricing for regional AKS and GKE clusters. Add in additional node costs for running your workloads and before you know it, you’re running a hefty monthly bill. Here are some potential ways to address computer and … -
Django News - New Wagtail Release and results from the Django Developers Survey 2020 - Aug 14th 2020
News Wagtail 2.10 Released A major new release with a configurable workflow system, full page and site history, a design overhaul of the page editor, Django 3.1 support, search query expressions, bulk redirect importing, and more. wagtail.io HTTPX 0.14.0 Released A major new release in HTTPX, the async successor to Requests. github.com Django Developers Survey 2020 Results from the Django Developers Survey 2020 were released. google.com Python Insider: Python 3.9.0rc1 is now available Python 3.9.0 is almost ready. This release, 3.9.0rc1, is the penultimate release preview. blogspot.com Deadline to nominate someone for Quarter 3 consideration is August 20, 2020 If you want to recommend someone to be a PSF Fellow, you have until August 20th to do so. python.org Events Django Boston August 2020 Virtual Event Benjamin "Zags" Zagorsky will present "Rapid Prototyping in Django," a distilled set of lessons and recommendations for how to build a functional Django website in 2 days and not regret it later. meetup.com Articles Django Views — The Right Way An opinionated guide on how to write views in Django. github.io Using Postgres JSONB Fields in Django In-depth look at using Postgres JSONFields in Django. pganalyze.com Customize the Django Admin With Python A guide … -
Deploying Django to AWS ECS with Terraform
In this tutorial, we'll look at how to deploy a Django app to AWS ECS with Terraform. -
Rendering Calendars - Building SaaS #68
In this episode, I worked on rendering a calendar of important events in a school year. We built out the appropriate data structures, and I wrote some new model methods and added tests. On the last stream, I created a new model to track breaks in the school year. The app now shows the calendar for the school year, and I want to display the breaks on the calendar. Before digging too far into the code, I provided my thoughts about using Docker for development from a question that came from the chat. -
Fixing Up Permissions After Data Migration in Django
Hello djangonauts, today I wanna talk about a problem that I faced while working with Django. So here’s the thing I just recently performed a major release at work, the database had to be changed since we had newer migrations and database structure. Naturally I had to import some data from my older database to the new one, which for most of the part could safely be done using fixtures (or so I thought). So I would like to share some tips and things that I learned recently because of it. Tip #1 Always exclude the Content Type table while exporting a fixture for data migration. It can be done as follows: python manage.py dumpdata --exclude=contenttypes Why? You may ask? It’s because Django automatically creates these records when you perform the migrations for your apps. These records are basically used by django internally for schema management. So if you import them from the older database, Django would raise errors. Tip #2 Now if you were like me, you might have dumped your permissions records as well into the fixture, that’s where the fun part comes in. Now since content type was created afresh for the newer database, so their ids … -
August 2020 Courses
Live, Interactive, Online Courses For years Audrey and I have travelled giving in-person training sessions. With current events being what they are, I've switched to giving live, online, interactive trainings using Zoom meeting software. This has involved some major refactoring of content. Here are the upcoming courses on my calendar: August 14: Django Best Practices the Two Scoops Way August 21, 22, 23: Django Crash Course Live -
August 2020 Courses
Live, Interactive, Online Courses For years Audrey and I have travelled giving in-person training sessions. With current events being what they are, I've switched to giving live, online, interactive trainings using Zoom meeting software. This has involved some major refactoring of content. Here are the upcoming courses on my calendar: August 14: Django Best Practices the Two Scoops Way August 21, 22, 23: Django Crash Course Live -
Distributed Locking in Django
As you start scaling an application out horizontally (adding more servers/instances), you may run into a problem that requires distributed locking. That's a fancy term, but the concept is simple. Sometimes you have to be sure that when a block of code is running (usually modifying data somewhere), no other instances runs that same block of code. Ideally, you can design your code not to require locks, but sometimes it is inevitable. In general, locks are used when you need to modify state (e.g. the database) in an atomic manner. Some examples of when you might need a distributed lock: Cron jobs/scheduled tasks whose runtime may exceed the interval with which they are triggered Flushing a write-back cache to the database. Bulk processing files If running the code on multiple servers simultaneously would result in corrupted or duplicate data, you probably need to use a distributed lock. The code in question will acquire the lock before execution. Once it has the lock, any other attempt to acquire it will fail. Implementations Lock data must be stored in a location accessible to all application instances. If this is a standard Django site, you probably already have two such systems available to … -
Distributed Locking in Django
As you start scaling an application out horizontally (adding more servers/instances), you may run into a problem that requires distributed locking. That's a fancy term, but the concept is simple. Sometimes you have to be sure that when a block of code is running (usually modifying data somewhere), no other instances runs that same block of code. Ideally, you can design your code not to require locks, but sometimes it is inevitable. In general, locks are used when you need to modify state (e.g. the database) in an atomic manner. Some examples of when you might need a distributed lock: Cron jobs/scheduled tasks whose runtime may exceed the interval with which they are triggered Flushing a write-back cache to the database. Bulk processing files If running the code on multiple servers simultaneously would result in corrupted or duplicate data, you probably need to use a distributed lock. The code in question will acquire the lock before execution. Once it has the lock, any other attempt to acquire it will fail. Implementations Lock data must be stored in a location accessible to all application instances. If this is a standard Django site, you probably already have two such systems available to … -
Fixing Up Permissions After Data Migration in Django
Find out how I fixed my permissions after I imported my data -
The best frontend JavaScript framework for Django
A question I've seen asked a lot is "what's the best frontend JavaScript framework to use with Django". Django itself doesn't make any recommendation on which frontend framework to use, or even assumes you're using a frontend framework at all. So, which frontend framework should you be using? And which one "plays well" with Django? Defining "the best" The problem with such questions is that "the best" is often ill-defined. Best based on what criteria? If you're starting a new project and wondering which one to choose, the disappointing answer I have for you is this: The best frontend JavaScript framework is one you already know well That's it. If you, or your team, wants to use a frontend framework, the best one to use is the one that you and your team have the most familiarity with. That's because it's very likely that you will be more productive with it. Django "plays well" with any frontend JavaScript framework, by virtue of the fact that it makes no assumptions and does not force you to use any framework. In that respect, it's all the same. At the end it's all JavaScript. The actual question But of course, that's not what … -
Django tarpit for malicious requests
While checking my logs for this site and seeing the usual malicious requests against every spammers favorite software WordPress I decided to make things a little harder for them with a [tarpit](https://en.wikipedia.org/wiki/Tarpit_(networking)). -
Thoughts on „Surviving Django“
Daniele, the author of psycopg2, wrote an interesting post about Django and its migration system. Having used Django for well over a decade and having worked on projects either handed to me or greenfield at different scales I cannot agree with his arguments as they are stated. The migration and ORM system does solve a far larger problem than allowing web apps to switch between databases. Djangos migration system is primarily a developer tool. A rather excellent one I cannot praise enough. It abstracts and standardises the way database migrations are handled. Remember following a document outlining the order of 15 migrations to apply when doing a deploy? Remember trying to add a 16th? I surely prefer running makemigrations. Is it perfect? No. Can a talented DBA get far more out of a database? Absolutely. Is any of that more relevant than safeguards and ease of use for 90% of the apps out there? Definitely not. Now to the really good part – you can have the best of both worlds! Migrations can run Python and SQL, while still giving you some of the safeguards and making it comfortable to use. They will not get in your way, but spare … -
Thoughts on „Surviving Django“
Daniele, the author of psycopg2, wrote an interesting post about Django and its migration system. Having used Django for well over a decade and having worked on projects either handed to me or greenfield at different scales I cannot agree with his arguments as they are stated. The migration and ORM system does solve a far larger problem than allowing web apps to switch between databases. Djangos migration system is primarily a developer tool. A rather excellent one I cannot praise enough. It abstracts and standardises the way database migrations are handled. Remember following a document outlining the order of 15 migrations to apply when doing a deploy? Remember trying to add a 16th? I surely prefer running makemigrations. Is it perfect? No. Can a talented DBA get far more out of a database? Absolutely. Is any of that more relevant than safeguards and ease of use for 90% of the apps out there? Definitely not. Now to the really good part - you can have the best of both worlds! Migrations can run Python and SQL, while still giving you some of the safeguards and making it comfortable to use. They will not get in your way, but spare … -
Django News - Django 3.1 Release - Aug 7th 2020
News Django 3.1 Released 3.1 is live! You can read the release notes. Please take a moment to thank our two Django Fellows, @MariuszFelisiak and @carltongibson, who made this release possible. djangoproject.com Django REST Framework 3.11.1 Released github.com Upgrade to pip 20.2, plus, changes coming in 20.3 The newest version of pip, 20.2, is now released. You can install it by running python -m pip install --upgrade pip. blogspot.com Django bugfix releases issued: 3.0.9 and 2.2.15 djangoproject.com Python Developers Survey 2019 Results The results of JetBrains' annual survey is out. jetbrains.com Articles Django 3.1 Async Django 3.1 introduces asynchronous views, middlewares, and tests. This article walks you through those features. wersdoerfer.de A breakdown of how NGINX is configured with Django Matt Segal covers Nginx in depth. mattsegal.dev Backporting a Django ORM Feature with Database Instrumentation How to use database instrumentation to backport a Django ORM feature. adamj.eu Some SQL Tricks of an Application DBA Haki Benita's guide to non-trivial tips for database development. hakibenita.com Goodconf: A Python Configuration Library Lincoln Loop recently released Goodconf and this is their guide to why and how to use it. lincolnloop.com Why you shouldn’t remove your package from PyPI Gonçalo Valério covers how to … -
How 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 the venerable jQuery, it won't work with modern JS native fetch API out of the box. … Read now -
Introducing Django ClearCache 🤠🧹💰 - allows to clear cache via admin UI or command line
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 checked online and found a couple of clear cache packages for Django, but all of them … Read now -
Brief 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 of knowledge or a feeling in me. So I decided to remember them all and try to … Read now -
The Simplest Way to Create a Python Virtual Environment
A lot of fog and mysteries surround Python virtual environments. There are loads of packages, tools, and wrappers trying to make developer's life with virtual environments easier. But if we look at the basics, we'll see that actually, creating a virtual environment in Python has never been easier. Starting from … Read now -
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 a simplified version of both models: class Post(models.Model … Read now -
Non-Django issues during a Django upgrade
Upgrading from Django 3.0.9 to 3.1 was a breeze. To be fair upgrading Django is usually a breeze. The exhausive release notes written every time a new version is rolled out is a defining factor here. What do I mean when I say “a breeze”? I compare Django “upgrades” to something like upgrading a Python 2 codebase to Python 3 😬 So, upgrades being a breeze, why write a post about this topic? Because a Django application usually does not comprise only of the Django package. How I upgraded This section basically is about “how I usually upgrade”. Made specific for this 3.0.9 to 3.1 upgrade. Steps Changed Django version in requirements.txt file. I.e. changed entry from Django==3.0.9 to Django==3.1. Ran pip install -r requirements.txt with the updated requirements file. Among the command’s output I spotted: Installing collected packages: Django Found existing installation: Django 3.0.9 Uninstalling Django-3.0.9: Successfully uninstalled Django-3.0.9 Successfully installed Django-3.1 Ran ./manage.py check This yielded several warnings of the type: $ ./manage.py check System check identified some issues: WARNINGS: app_name.Model.field_name: (fields.W904) django.contrib.postgres.fields.JSONField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0. HINT: Use django.db.models.JSONField instead. ... System check identified 3 issues … -
Thoughts on „Surviving Django“
Thoughts on „Surviving Django“ Daniele, the author of psycopg2, wrote an interesting post about Django and its migration system. Having used Django for well over a decade and having worked on projects either handed to me or greenfield at different scales I cannot agree with his arguments as they are stated. The migration and ORM system does solve a far larger problem than allowing web apps to switch between databases. Djangos migration system is primarily a developer tool. A rather excellent one I cannot praise enough. It abstracts and standardises the way database migrations are handled. Remember following a document outlining the order of 15 migrations to apply when doing a deploy? Remember trying to add a 16th? I surely prefer running makemigrations. Is it perfect? No. Can a talented DBA get far more out of a database? Absolutely. Is any of that more relevant than safeguards and ease of use for 90% of the apps out there? Definitely not. Now to the really good part - you can have the best of both worlds! Migrations can run Python and SQL, while still giving you some of the safeguards and making it comfortable to use. They will not get in …