Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
[Django]ticket#373
ticket#373(Add support for multiple-column primary keys) is discribed in Django Wiki below. https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys Below is my opinion on this and how to implement django-compositepk-model. 0. about django-compositepk-model Regarding the support for composite primary key, I think it would be a good to modify the Django model, but I can’t wait in a situation where I don’t know if it will be supported. One proposal is to proceed with my own branch separated from Django main, but that’s not good considering future maintenance. So, I decided to make package to extend Django model. There is a stupid implementation that overrides and copies the source back to change only one line, but I think the basics are hooked well. SQLite DB with test data set is on GitHub, and you can execute the Admin, so if interested, please try it. https://github.com/Arisophy/django-compositepk-model/tree/main/compositepk-model/test 1. MajorIssues written on the Wiki https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys#MajorIssues 1.1 _meta.pk A number of APIs use “obj._meta.pk” to access the primary key, on the assumption it is a single field (for example, to do “pk=whatever” lookups). A composite PK implementation would need to emulate this in some way to avoid breaking everything.Django Community Wiki 1) multi field support In CPKModel, what is set … -
The Three Kinds of Organizational Power
Within an organization, there are three kinds of power structures: role power, relationships, and expertise. Understanding these kinds of power — how they’re built; how they’re wielded; ethically and otherwise; what they can and can’t accomplish — is key to understanding organizations at a systemic level and maximizing your effectiveness at work. -
Weeknotes (2021 week 10)
Weeknotes (2021 week 10) I’m trying out the weeknotes format to hopefully write a bit more 😄. feincms3: Page types and moving torwards a 1.0 release The current beta release of feincms3 (0.90b*) introduces support for page types. This new concept unifies templates and apps. Since feincms3 apps can basically do what they want it didn’t make much sense to force managers to choose a template when they already selected an app. Sometimes, we offered managers a “projects” template and a “projects” app and they had to select both. This duplication was hard to explain and justify. This isn’t the only backwards-incompatible change in 0.90b*. The default image plugins now always have a caption and an alternative text field; the versatileimagefield-based plugin is gone as are the shims in feincms3.apps. The idea is to release a 1.0 of feincms3 soon-ish. It’s time to do this. feincms3 is in its fifth year of existence, several sites built with it have already been archived already, so it’s definitely past due. (django-content-editor (resp. FeinCMS 1.x) more than 12 years old now.) django-mptt is not maintained anymore We, the maintainers of django-mptt have marked django-mptt as unmaintained. I have released the current development version … -
Weeknotes
Weeknotes I’m trying out the weeknotes format to hopefully write a bit more 😄. feincms3: Page types and moving torwards a 1.0 release The current beta release of feincms3 (0.90b*) introduces support for page types. This new concept unifies templates and apps. Since feincms3 apps can basically do what they want it didn’t make much sense to force managers to choose a template when they already selected an app. Sometimes, we offered managers a “projects” template and a “projects” app and they had to select both. This duplication was hard to explain and justify. This isn’t the only backwards-incompatible change in 0.90b*. The default image plugins now always have a caption and an alternative text field; the versatileimagefield-based plugin is gone as are the shims in feincms3.apps. The idea is to release a 1.0 of feincms3 soon-ish. It’s time to do this. feincms3 is in its fifth year of existence, several sites built with it have already been archived already, so it’s definitely past due. (django-content-editor (resp. FeinCMS 1.x) more than 12 years old now.) django-mptt is not maintained anymore We, the maintainers of django-mptt have marked django-mptt as unmaintained. I have released the current development version as 0.12.0 before … -
Django News - git checkout main: This is the way. - Mar 12th 2021
News Django Project Primary Git branch renamed The Django Project renamed the primary branch of the Django git repository from "master" to "main". If you run tests against a nightly checkout, you may need to adjust your CI targets. google.com NASA’s Jet Propulsion Laboratory launches on Wagtail CMS The eyes of the world turned to JPL as the Perseverance Rover touched down on Mars. They did so via the new jpl.nasa.gov site, the Lab’s digital home for missions, science news, images and videos, recently redesigned and rebuilt on Wagtail. torchbox.com Events PyOhio 2021 - Save The Date! PyOhio is July 31, 2021, and their CFP opens on March 15. pyohio.org Sponsored Link RSVP for the 3rd Annual Python Web Conference (Virtual) | March 22-26, 2021 50+ talks on hard Python problems including Machine Learning, AI, Big Data, Django, Plone, CI/CD, Containers, etc. Join JetBrains and Six Feet Up to discuss what the future holds. pythonwebconf.com Articles Writing tests for the Django admin with pytest-django Django co-creator, Simon Willison, shows us how to write tests for the Django Admin to test a form submission. simonwillison.net Getting Started with Alpine.js Django Fellow Carlton Gibson shows us both a basic and a more … -
How Long Does It Take to Hire Someone?
How many hours does it take to hire someone, from approval of the open position to their first day? I tracked a recent hiring round I ran, and found it takes about 100 person-hours. Here’s a breakdown of where that time goes. -
Coworking With a Friend to Write More
In early January, Sumana Harihareswara and I started getting together a few times a week to help each other write more. This model of working together on separate-but-related projects has worked really well for us, and we wanted to share our model and our details to encourage other folks to give it a shot. -
“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. -
Distributed Testing with Selenium Grid and Docker
This post shows how to distribute automated tests with Selenium Grid and Docker Swarm. -
Using Django Check Constraints to Limit the Range of an IntegerField
Another way to use database constraints via Django’s CheckConstraint class. A classic bit of data validation is to check input numbers lie within a given range. This can prevent accidents such as the NHS recently recording a journalist’s height as of 6cm and thus calculating his BMI as 28,000. The default field numerical field types in Django have ranges that match the limits of database support. For example, IntegerField supports the range -2,147,483,648 (-231) to 2,147,483,647 (231 - 1). Suffice to say, most applications only deal with numbers in more limited ranges. For example, imagine we are selling books. We know the price cannot be negative, so we use PositiveIntegerField: from django.db import models class Book(models.Model): ... price_pence = models.PositiveIntegerField() This is a good start, however we still support prices up to £21,474,836.47 ( How to How Django uses some constraints already See SQlite connection data_type_check_constraints for positive integer field constraints -
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 … -
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 -
Load Webpack bundles in Django
Learn how to load Webpack bundles in Django and the difference between development and production mode in Webpack -
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. -
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", … -
Running Flask on Docker Swarm
This post looks at how to run a Flask app on Docker Swarm.