Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django REST Framework Views - ViewSets
This article takes a deep dive into Django REST Framework's most powerful view, ViewSets. -
Django News - Python 3.10 and PostgreSQL 14 Release - Oct 1st 2021
News PostgreSQL 14 Released! The PostgreSQL Global Development Group announced the release of PostgreSQL 14, the latest version of the open-source database. postgresql.org What’s New In Python 3.10 New syntax features, additions to the standard library, typing features, and a few deprecations. python.org Python 3.10 Release Stream Python 3.10 is set to be released on 4 October 2021. Join us live in our Python 3.10 Release Stream with Pablo Galindo, CPython Core Developer and Python 3.10 Release Manager, and Leon Sandøy. youtube.com Events Django Girls Mentors needed for DjangoCon US DjangoCon US is partnering with Django Girls and we're looking for mentors. Please visit our signup form. We are looking for 15 engineers to help with one of the most rewarding aspects of Open Source Software: bringing new people into the community! We look forward to seeing you there! djangogirls.org Sponsored Jobs 💼 Canopy is hiring software engineers! We are seeking experienced software engineers to join our talented engineering team. We provide social impact programs evaluation & technical tools to maximize success! canopyteam.org Articles New Testing Features in Django 4.0 Django 4.0 had its first alpha release last week and the final release should be out in December. It contains … -
High Performance Django Is Free Online
In 2014 Yann Malet and I (with the help of the rest of the team here) wrote a book about building and scaling Django websites. It was the culmination of things we'd learned from, at the time, close to a decade of experience building, deploying, and supporting Django sites. It's been seven years since its release and it's fair to say that the book has run its course. While I didn't feel good about continuing to sell the book given its age, I also believe it still contains a lot of valuable information. As you'd expect, after seven years, many of the technical examples are outdated. The book, however, is largely conceptual. Code snippets are rarely the "secret sauce" when scaling a site. Topics such as caching and reducing/optimizing database queries aren't usually coding challenges. In fact, thanks to the stability of Django, much of that code is still the same today. So instead of relegating the book to the dustbin, we're releasing it for free online. It's something we've wanted to do for a long time and I'm excited to finally get the book in more people's hands. You can find it on this site at https://lincolnloop.com/high-performance-django/. -
High Performance Django Is Free Online
In 2014 Yann Malet and I (with the help of the rest of the team here) wrote a book about building and scaling Django websites. It was the culmination of things we'd learned from, at the time, close to a decade of experience building, deploying, and supporting Django sites. It's been seven years since its release and it's fair to say that the book has run its course. While I didn't feel good about continuing to sell the book given its age, I also believe it still contains a lot of valuable information. As you'd expect, after seven years, many of the technical examples are outdated. The book, however, is largely conceptual. Code snippets are rarely the "secret sauce" when scaling a site. Topics such as caching and reducing/optimizing database queries aren't usually coding challenges. In fact, thanks to the stability of Django, much of that code is still the same today. So instead of relegating the book to the dustbin, we're releasing it for free online. It's something we've wanted to do for a long time and I'm excited to finally get the book in more people's hands. You can find it on this site at https://lincolnloop.com/high-performance-django/. Photo by … -
Bulk Delete View - Building SaaS with Python and Django #116
In this episode, I started a bulk delete view to make it possible for customers to delete many course tasks at once. -
Django REST Framework Views - Generic Views
This article looks at how to use Django REST Framework's Generic Views to prevent repeating certain patterns over and over again. -
Django 4.0
Django 4.0 alpha 1 released Django 4.0 release notes - UNDER DEVELOPMENT DjangoCon US 2021It’s About Time: DjangoCon US 2018 talk by Russell Keith-Mageeawesome-django repo Support the ShowThis podcast does not have any ads or sponsors. To support the show, please consider visiting LearnDjango.com or Button. -
New Testing Features in Django 4.0
Django 4.0 had its first alpha release last week and the final release should be out in December. It contains an abundance of new features, which you can check out in the release notes. In this post we’ll look at the changes to testing in a bit more depth. 1. Random test order with --shuffle¶ The release note for this reads: Django test runner now supports a --shuffle option to execute tests in a random order. I’m delighted that Django now has this option. It gives us strong protection against non-isolated tests. When tests are not isolated, one test depends on the side effect from another. For example, take this test case: from django.test import SimpleTestCase from example.core.models import Book class BookTests(SimpleTestCase): def test_short_title(self): Book.SHORT_TITLE_LIMIT = 10 book = Book(title="A Christmas Carol") self.assertEqual(book.short_title, "A Chris...") def test_to_api_data(self): book = Book(title="A Song of Ice and Fire") self.assertEqual( book.to_api_data(), {"title": "A Song of Ice and Fire", "short_title": "A Song ..."}, ) The tests pass when run forwards (test_short_title first), but fail in reverse. This is because test_short_title monkeypatches Book.SHORT_TITLE_LIMIT to a new value, and test_to_api_data’s expected data depends on this change. Non isolated tests can arise all too easily in an evolving … -
Django REST Framework Views - APIViews
This article takes a deep dive into how Django REST Framework's views work and its most basic view, APIView. -
Creating dynamic RSS feed with parameters
<![CDATA[ Creating dynamic RSS feed with parameters Setting up basic RSS feed with Django is pretty quick process thanks to Syndication framework included in Django. And it turns out setting up RSS feed that takes a parameter is not significantly more involved. For my IndieAppsCatalog I wanted to generate separate RSS feeds for all categories, so people could follow just "Productivity" category, for example. Let's see how this is done, with emphasis on what is different from setting up basic RSS. Setting up the feed You need a way to identify the "base object" the RSS feeds uses. For that we can use get_object method: class NewlyAddedAppsByCategory(Feed): author_name = "Indie Apps Catalog" def get_object(self, request, category_id, **kwargs): return AppCategory.objects.get(appstore_id=category_id) This is the key difference from basic RSS feeds which don't make use of the get_object method. Next you can change properties of the feed like title, link or description to be methods which allows you to customize them based on the category. For example: def title(self, obj): return "IndieAppsCatalog: Newly added apps to '{0}'".format(obj.display_name) def link(self, obj): return obj.get_absolute_url() The obj is AppCategory instance so we can use its display_name property to customize title for this RSS feed. Customizing what … -
Briefing a Delegate
Some managers think delegation is easy: you just ask someone on your team to go do a thing, then kick back with your feet on the desk until it’s done. Not true: delegating that way is a recipe for failure. To delegate effectively, you need to set up your delegate for success. This means explaining the work and desired outcomes, providing context, and teaching your delegate any skills they’ll need to be successful. -
How to load a Service Worker in Django
A service worker, part of the family of web workers, is, to put it shortly, a particular type of JavaScript code which can run off the main thread of execution. This has a number of benefits. In particular, service workers make possible to augment web applications with offline capabilities, and fine-grained cache management. In this brief post we see how to load a service worker in Django. The shortest introduction ever to service workers To put it simply, a service worker is like a proxy sitting in between the network and the web application. How to use a service worker? In its simplest form, we can load a service worker from any web page of the application, as in the following example: // Place this preferably in your app entry point: if ("serviceWorker" in navigator) { window.addEventListener("load", () => { navigator.serviceWorker .register("/service-worker.js") .then(registration => console.log("Service worker registered", registration) ) .catch(err => console.log(err)); }); } Here we check that the browser supports service workers, and we wait for the load DOM event before triggering the service worker registration: // navigator.serviceWorker .register("/service-worker.js") // This snippet is really important, and we can notice that we load our service worker from the root of … -
Django News - Django 4.0 alpha 1 released - Sep 24th 2021
News Django 4.0 alpha 1 released Django 4.0 alpha 1 is now available. It represents the first stage in the 4.0 release cycle and is an opportunity for you to try out the changes coming in Django 4.0. djangoproject.com Zappa is now deprecated Zappa was a serverless Python project that attracted wide attention. Unfortunately, the maintainers do not have the time to keep it alive. Feel free to fork and have a go at it if you have the time and inclination. github.com awesome-django now has discussions! The awesome-django repo repo now has 4.4k stars and is managed by Jeff Triplett and William Vincent. github.com Katia Lira Awarded the PSF Community Service Award for Q2 2020 Katia Lira, Software Engineer from Mexico city, has been awarded the Python Software Foundation 2020 Q2 Community Service Award. Katia is the President of DEFNA and a DjangoCon US organizer. blogspot.com Sponsored Jobs 💼 Canopy is hiring software engineers! We are seeking experienced software engineers to join our talented engineering team. We provide social impact programs evaluation & technical tools to maximize success! canopyteam.org Articles How to Decouple Your App From its Operating System with Docker See how we upgraded the version of Python … -
Finish School Break Filtering - Building SaaS with Python and Django #115
In this episode, we finished the UI work and wrote the final tests needed to complete the school break filtering by student feature. -
Cloning a Single Production Database Table from Heroku to Local Database with PostgreSQL in Docker Compose
I have a few Django apps in a Django project. I used factory_boy to mock a bunch of the data, but I have a few hundred rows of… -
Cloning a Single Production Database Table from Heroku to Local Database with PostgreSQL in Docker Compose
I have a few Django apps in a Django project. I used factory_boy to mock a bunch of the data, but I have a few hundred rows of accurate data in my production database. It made sense to work on a copy of that data as it contains no sensitive user information. My project is hosted on Heroku with one of their free tier PostgreSQL databases. My local environment is a Docker Compose stack with images for Python, PostgreSQL, and Redis. The trickiest part here, in my opinion, is finding out just how to get the backup to the PostgreSQL docker container. Table of Contents Table of Contents Backup the Production Database Clone to Local Database Conclusion Backup the Production Database There are two easy ways to do this on Heroku Use the Heroku CLI Use the Heroku web interface The Heroku docs detail how to make a backup. Use the Heroku CLI to Backup Database So first, if you aren’t already using it, you’ll need to install the Heroku CLI and run heroku login. Next, you’ll need to know your app’s name in Heroku. Mine is mastering-fitness, but you can get a list of all your Heroku apps right … -
People- vs Results-Oriented Management: Both Work!
Broadly speaking, there are two management styles: people-oriented and results-oriented management. Taken to extremes both styles have failure modes, but seeking “balance” isn’t the answer. Both modes can be successful! Embrace the style that comes easiest to you, while learning enough about the other mode to avoid pitfalls. -
How to keep all your websites in sync with scraping technology
Would you like to pull in the header and/or footer from a related but separate website for use on your own pages? Here's how. Introduction Many of our clients maintain multiple websites, or multiple domains within a single website. For example, "store.example.com" and "www.example.com" will almost always be different websites. In many instances, the different websites are maintained by different vendors; however, most have at least some elements in common, such as logos, headers, footers, etc. Often, when deploying a new site, these shared elements are simply copied and pasted from the main site. This is quick and easy to do, but the downside of this approach is that when someone inevitably changes a logo or other shared element on the main site, the element that should be universal across both sites will go out of sync. Such "quiet" errors might go unnoticed for long stretches of time. When they are noticed, it might take some digging to figure out what changed and whether any other websites or subdomains have been affected. How often does this happen? Doing a quick Google search of "store." yielded store.playstation.com. Here's a screenshot of the footer of store.playstation.com and playstation.com: store.playstation.com www.playstation.com Now, these two … -
Django News - Redis support for Django 4.0! - Sep 17th 2021
News Django 4.0 will feature built-in Redis backend! Thanks to Google Summer of Code student Daniyal Abbasi, Django 4.0 will feature built-in Redis support! github.com Sponsored Jobs Canopy is hiring software engineers! We are seeking experienced software engineers to join our talented engineering team. We provide social impact programs evaluation & technical tools to maximize success! canopyteam.org Articles Introducing django-upgrade, a tool for upgrading your Django projects A new tool from Django Security Team member Adam Johnson. Looks amazing! adamj.eu Understand Django - User File Use The latest installment in this series from Matt Layman covers file management, such as accepting images/files from users. mattlayman.com Bulk update with django and htmx Code and explanation for a very common issue: bulk uploads in Django. Using htmx no less. chriswedgwood.com Docker: From Development to Deployment with Django and Vue by Patrick Altman Patrick Altman shows us how he prefers to isolate his Django and Vue environment using Docker in a team-friendly and time-saving way. paltman.com AWS federation comes to GitHub Actions Are you underwhelmed when configuring AWS credentials to work with GitHub Actions? There is now another way. awsteele.com Tutorials How to Deploy Django using Caprover A tutorial on deploying Django using … -
Student Filtering UI - Building SaaS with Python and Django #114
In this episode, we worked on UI and form changes to enable the extra many to many filtering that enables school breaks to be applied to individual students. -
Introducing django-upgrade, a tool for upgrading your Django projects
Django deprecates a small list of features with every feature release, requiring us to update our projects, which can be monotonous. Today I’m announcing a new tool I’ve created, django-upgrade, that automates some of this drudgery for us all. The Story¶ For a while I’ve enjoyed using pyupgrade, which upgrades Python syntax to the latest and greatest. pyupgrade is both fast and accurate, what you’d hope for in such a tool. The idea is to run it continuously, via pre-commit or similar, so that any new usage of old syntax you add gets automatically upgraded. Last year, after a django-developers discussion, Bruno Alla created a similar tool for upgrading Django projects called django-codemod. django-codemod works well, and I’ve enjoyed running it on a few projects, saving me hours of boring find-and-replace. The only downside is that it’s relatively slow, taking up to several minutes on a medium sized project. This makes it okay for one-off runs, but it’s not suitable for running continuously (except on CI). django-codemod’s slowness is due to the underlying library, LibCST, which implements its parser in Python. In contrast, pyupgrade is fast because it uses Python’s own C-based parser. LibCST also comes with compatibility concerns - … -
User File Use
In the last Understand Django article, you learned about Django settings and how to manage the configuration of your application. We also looked at tools to help you to be extra effective with settings. With this article, we’re going to dig into file management. Unlike the static files that you create for the app yourself, you may want your app to accept files from your users. Profile pictures are a good example of user files. -
User Session Data
Full show notes are available at https://www.mattlayman.com/django-riffs/15. -
Episode 15 - User Session Data
On this episode, we will dig into a data storage technique that Django makes heavy use of for visitors to your site. This category of data is called session data. Listen at djangoriffs.com or with the player below. Last Episode On the last episode episode, we looked at what it takes to go live and how to prepare your Django project for the internet. What Is A Session? A session is a set of data that is available to users that Django can use over multiple requests. -
Django News - Python 3.7.12 and 3.6.15 released - Sep 10th 2021
News Python Insider: Python 3.7.12 and 3.6.15 security updates now available Python 3.7.12 and 3.6.15, the latest security fix rollups for Python 3.7 and Python 3.6. blogspot.com PSA: Python 3.6 will stop getting security updates in December 2021. Via Itamar Turner-Trauring python.org Events Join the PyCon US 2022 team! Want to play a pivotal role in the planning and success of PyCon US? Here’s your chance! blogspot.com Sponsored Link REVSYS We’re senior Django developers, ops people, and consultants who have deep and vast experience to pull from. We know what works and what doesn’t. We have been where you are before (probably many times). Let us guide you onto a better path. revsys.com Articles Technical documentation writing quick tips by Marijke Luttekes An assortment of quick tips to help you make your technical documentation (docstrings, READMEs) easier to read. marijkeluttekes.dev Django React Boilerplate Learn how to bundle Django and React and code a full-stack boilerplate using this modern stack - with free samples. appseed.us Python Project-Local Virtualenv Management Hynek shows us his workflow for managing Python versions and what he considers the Python equivalent of node_modules using direnv. hynek.me Psycopg3 Initial Review psycopg3 is the successor to psycopg2, which is …