Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
“Why Did You Leave Your Last Job?”
Asking candidates why they left their last job is common… but should it be? I’m not sure. What do you think? -
Django News - Happy Birthday Python and DjangoCon Europe's CFP is open - Mar 5th 2021
News Happy Anniversary to Python and the Python Software Foundation! This week Python turned 30, and the Python Software Foundation turned 20 years old. In celebration, the PSF has a membership drive with the goal of getting 2,000 new or renewing members over the next 30 days. If you aren't a basic member, there is both a free and $99/year option to support the foundation. blogspot.com Python Developers Survey 2020 Results JetBrains has released its annual Python developer survey which is full of graphics and interesting info on how the community uses Python in practice. jetbrains.com Wagtail CMS: Accessibility team reloaded After 6 months of operations, we reflect on the progress our accessibility team has made and go on the lookout for new contributors. wagtail.io Events DjangoCon Europe 2021 CFP is open The Call for Proposals is open for DjangoCon Europe 2021 and are due by April 1. djangocon.eu PyCon AU 2021 Following the success of PyConline AU 2021, and with the lack of certainty in the world, PyCon AU is again running virtually in 2021 as PyConline AU, in UTC+10 (Australian Eastern Standard Time). We intend to run in late Q3 (~ September), but we have yet to confirm … -
How to Give a Status Update To Executives
Here’s a weird little skill I had to learn the hard way: how to give a status update to executives, investors, or boards. It’s different from most other kinds of status updates: much shorter, much quicker, much less in-depth. Here’s the structure I use when giving an update to this type of audience. -
High Performance Django - Peter Baumgartner
Lincoln LoopAppPackHigh Performance Django bookPeter on TwitterDjangoCon 2015: Django Developments Done RightDjangoCon 2010: Scaling the World’s Largest Django App by David Cramer & Jason YanSupport the ShowThis podcast is a labor of love and does not have any ads or sponsors. To support the show, please consider recommending a book from LearnDjango.com, signing up for the free weekly Django News newsletter, or learning more about Button a simpler deployment story for Django. -
Wagtail get_absolute_url, without domain
Django models are usually created with a get_absolute_url method, but Wagtail pages don't have one. On this site I mix Wagtail pages with other Django models and needed an url without a domain in some places, below is the solution I'm using right now. Most methods to get a page page seem to want a request object and add the domain, but I just wanted the full path to the page. Raw from wagtail.core.models import Page class MyPage(Page): def get_absolute_url(self): try: site_id, site_root_url, relative_page_path = self.get_url_parts() ret = relative_page_path except TypeError: ret = None return ret -
Exciting New Features in Django 3.2
Django 3.2 is just around the corner and it's packed with new features. Django versions are usually not that exciting (it's a good thing!), but this time many features were added to the ORM, so I find it especially interesting! This is a list of my favorite features in Django 3.2 Image from the Django welcome page A lot of great people worked on this release and none of them is me. I included links to the tickets of each new feature to show my appreciation to the people behind it. Table of Contents Covering Indexes Provide Timezone to TruncDate Building JSON Objects Loud Signal Receiver QuerySet Alias New Admin Decorators Value Expression Detects Type More Mentionable Features Wishlist ⚙ Setup local environment with the latest version of Django To setup an environment with the latest version of Django start by creating a new directory and a virtual environment: $ mkdir django32 $ cd django32 $ python3.9 -m venv venv $ source venv/bin/activate To install the latest version of Django you can either install using pip, or if it hasn't been released yet, install directly from git: (venv) $ pip install git+https://github.com/django/django@3.2a1 Start a new project and app: (venv) $ … -
Semantic Versioning Will Not Save You
The widely used Python package cryptography changed their build system to use Rust for low-level code which caused an emotional GitHub thread. Enthusiasts of 32-bit hardware from the 1990s aside, there was a vocal faction that stipulated adherence to Semantic Versioning from the maintainers – claiming it would’ve prevented all grief. I will show you not only why this is wrong, but also how relying on Semantic Versioning hurts you. -
Types of Interview Questions
There are three types of interview questions: behavioral, hypothetical, and trivia. Behavioral questions are the gold standard; they’re the most effective at predicting job performance. Hypothetical questions can be useful in certain circumstances, if used correctly. Avoid trivia. -
How MDN's site-search works
tl;dr; Periodically, the whole of MDN is built, by our Node code, in a GitHub Action. A Python script bulk-publishes this to Elasticsearch. Our Django server queries the same Elasticsearch via /api/v1/search. The site-search page is a static single-page app that sends XHR requests to the /api/v1/search endpoint. Search results' sort-order is determined by match and "popularity". Jamstack'ing The challenge with "Jamstack" websites is with data that is too vast and dynamic that it doesn't make sense to build statically. Search is one of those. For the record, as of Feb 2021, MDN consists of 11,619 documents (aka. articles) in English. Roughly another 40,000 translated documents. In English alone, there are 5.3 million words. So to build a good search experience we need to, as a static site build side-effect, index all of this in a full-text search database. And Elasticsearch is one such database and it's good. In particular, Elasticsearch is something MDN is already quite familiar with because it's what was used from within the Django app when MDN was a wiki. Note: MDN gets about 20k site-searches per day from within the site. Build When we build the whole site, it's a script that basically loops over … -
Django News - Django 3.2 beta & Python 3.9.2 - Feb 26th 2021
News Django security releases issued: 3.1.7, 3.0.13 and 2.2.19 As ever, the best security policy is to stay up-to-date with the latest release of Django. djangoproject.com Django 3.2 beta 1 released Django 3.2 beta 1 is now available. It represents the second stage in the 3.2 release cycle and is an opportunity for you to try out the changes coming in Django 3.2. djangoproject.com Python 3.9.2 and 3.8.8 are now available Time to upgrade Python if you can! python.org Articles Simple In-Memory Caching of Django Model Data With cachetools by Adam Johnson An elegant way to fix an N+1 problem. adamj.eu Building web apps with Vue and Django - The Ultimate Guide A look at multiple approaches for combining Django & Vue. dafoster.net Setup Webpack Project with Django A series on combining Webpack with Django. accordbox.com Interview Question Series Wrap Up From Jacob Kaplan-Moss, a series on good interview questions to ask. jacobian.org Comprehending Class-Based Views in Django - Generic Views The 3rd in a series on using CBVs in your applications, this one focuses on generic views. brennantymrak.com Sponsored Link RSVP for the 3rd Annual Python Web Conference (Virtual) | March 22-26, 2021 50+ talks on hard Python problems … -
Load Webpack bundles in Django
Learn how to load Webpack bundles in Django and the difference between development and production mode in Webpack -
Using Django Check Constraints to Prevent Self-Following
Another way to use Django’s CheckConstraint class to ensure your data is valid. Based on my answer to a question on the Django forum. Imagine we have a user model that we’d like to introduce a social media “following” pattern to. Users can follow other users to receive updates on our site. We’d like to ensure that users do not follow themselves, since that would need special care in all our code. We can block self-following in the UI layer, but there’s always the risk that we’ll accidentally enable it. For example, we might add an “import your contacts” feature that allows self-following. As with all the other posts in this series - the best way to prevent bad data is to block it in the database. Setting up the relationship To add the followers relationship, we’ll be using ManyToManyField. By default, ManyToManyField creates a hidden model class to hold the relationships. Because we want to customize our model with add an extra constraint, we’ll need to use the through argument to define our own visible model class instead. We can define a first version of this like so: from django.db import models class User(models.Model): ... followers = models.ManyToManyField( to="self", … -
Effective Organizations Value Autonomy
I believe that autonomy is one of the most important values of effective organizations. But I also think it’s a value that’s misunderstood and misapplied. In this post, I’ll (1) define what I mean by “autonomy”, (2) explain what autonomy isn’t, and (3) try to articulate why autonomy, as an organizational value, leads to higher effectiveness. -
Adding Charts to Django with Chart.js
In this tutorial, we'll look at how to add interactive charts to Django with Chart.js. -
Testing Image Generation
I figured out how to write an assert_images_equal function for testing that a generated image matches an expected one. It’s a lot simpler than I’d have thought, and the results are great! -
Effective Organizations Value Autonomy
I believe that autonomy is one of the most important values of effective organizations. But I also think it’s a value that’s misunderstood and misapplied. In this post, I’ll (1) define what I mean by “autonomy”, (2) explain what autonomy isn’t, and (3) try to articulate why autonomy, as an organizational value, leads to higher effectiveness. -
Test Your Apps
In the previous Understand Django article, we saw how static files like CSS, JavaScript, and images can be incorporated into your site. Now we’re going to focus on how to verify that your website works and continues to work by writing automated tests that check your pages and your code logic. From Browser To DjangoURLs Lead The WayViews On ViewsTemplates For User InterfacesUser Interaction With FormsStore Data With ModelsAdminister All The ThingsAnatomy Of An ApplicationUser AuthenticationMiddleware Do You Go? -
Improve your Django experience with IPython
IPython is an improved Python shell for interactive use. It has many great features such as syntax highlighting, autocomplete, and powerful “magic commands”. I love it, use it on every project, and use the IPython prompt for examples on my blog. IPython has too much goodness to cover here. Check out its tutorial for an introduction. To use IPython with Django, simply install it: $ python -m pip install ipython (Or add to your project’s requirements file.) Now Django’s shell will automatically use IPython: $ ./manage.py shell Python 3.9.1 (default, Jan 21 2021, 09:04:53) Type 'copyright', 'credits' or 'license' for more information IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: from db_buddy.core.models import Server| Server ServerKind ServerManager In this example, I typed Server then pressed “Tab” and IPython opened a drop-down of possible names to import. IPython’s debugger IPython also comes with an improved version of Python’s pdb debugger, with colorization and other features. Inside the IPython shell, if you code raises an exception, you can open the IPython debugger with the %debug magic command: In [1]: def divide(x, y): ...: return x/y ...: In [2]: divide(1,0) --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) <ipython-input-3-4fffc6193274> … -
Django’s release code words, up until 3.2
It’s now a long-running tradition that each Django release has an associated “code word”. This is used by the release manager in the announcement blog post to describe the list of features coming in the next version. I previously covered the code words used up until 2.2. This post is an update to expand the table up until Django 3.2, which had its first beta release yesterday. Each code word links to its Wiktionary entry so you can see the definition. The word frequency is the based on the data set provided by Peter Norvig based upon a Google 2012 corpus - higher means more occurrences of that word (in english). Version(Links to Announcement) Post Author Quote with Code Word Highlighted Word Frequency 1.7 James Bennett ...will bring several major new features to Django, along with a host of other improvements... 32,304,193 1.8 Tim Graham ...several major new features and a o cornucopia of other improvements... 330,288 1.9 Tim Graham ... myriad of goodies... 3,019,357 1.10 Tim Graham ... panoply of new features... 474,466 1.11 Tim Graham ... medley of new features... 963,448 2.0 Tim Graham ... assortment of new features... 2,252,068 2.1 Tim Graham ... smorgasbord of new features... … -
Django News - DjangoCon Europe is Virtual, Python, and Wagtail Releases - Feb 19th 2021
News DjangoCon Europe 2021 Announcement This year's DjangoCon Europe will be virtual only and held June 2-6. djangoproject.com Python 3.7.10 and 3.6.13 security updates now available Python 3.7.10 and 3.6.13, the latest security fix rollups for Python 3.7 and Python 3.6, are now available. blogspot.com Wagtail 2.12 and 2.11 Bugfixes Minor Wagtail versions 2.12.2, 2.12.1, 2.11.5, and 2.11.4 were released to address bug fixes. github.com Events PyCascades 2021 Remote is this weekend! Friday, February 19th, 2021, is the last day to purchase your PyCascades Remote 2021 tickets. Tickets range from $10 to $50. pretix.eu Articles New Testing Features in Django 3.2 Adam Johnson explores in-depth 5 new testing features in the forthcoming Django 3.2 release. adamj.eu Django and Stripe Payments Tutorial A video and text tutorial on adding Stripe Checkout to a Django website. justdjango.com Django and Pydantic How to integrate Pydantic with a Django application using the Pydantic-Django and Django Ninja packages. testdriven.io Quick and Dirty Django - Passing data to JavaScript without AJAX A clever quick & dirty way to proof of concept data without needing AJAX. hacksoft.io Why you really need to upgrade pip by Itamar Turner-Trauring In order to get the latest and greatest packages, without … -
Take Note of these Top Talks From DjangoCon EU
Photo by The Climate Reality Project on Unsplash Like many conferences in 2020, DjangoCon EU was held virtually. I'm glad I had the opportunity to attend because the sessions provided insight and information that I’m still applying. In light of the pandemic and the social changes it's caused, I've come to know that web development and the solutions it provides are at the heart of how we are navigating this challenging time. Here are three talks from DjangoCon EU that I believe will help you protect, maintain, and develop projects. Developing a Security Mindset: Practical Lessons for Pythonistas Hayley Denbraver Hayley used the great analogy of Sherlock Holmes and other detectives from fiction to help encourage the audience to take on a more security-oriented mindset in their Django projects. The talk touches upon a lot of topics in security, from how to think about third party dependencies and their security vulnerabilities, to mitigating the risk of SQL injection attacks and code execution from deserialized user content. All around, this talk was a great way to stay informed on the methodologies for protecting your application. C is for Cookie Russell Keith-Magee At Caktus many of our projects demand internationalization. As a … -
Django Forum - Ken Whitesell
2020 Malcolm Tredinnick Memorial Prize awarded to Ken WhitesellKen on Django ForumDjango Forum: Where to put business logic?Django models, encapsulation and data integrity by Tom ChristieDjango Hello, World 5 Different WaysSupport the ShowThis podcast is a labor of love and does not have any ads or sponsors. To support the show, please consider recommending a book from LearnDjango.com, signing up for the free weekly Django News newsletter, or learning more about Button a simpler deployment story for Django. -
Setup Webpack Project with Django
Setup a Webpack project with Django and run it in Watch mode. -
Success With Static Files
Full show notes are available at https://www.mattlayman.com/django-riffs/12. -
Interview Question Series Wrap Up
A summary and wrap-up of my Unpacking Interview Questions series, covering why I wrote this series in the first place, some advice on developing your own questions, and answers to a few questions.