Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
aiGrunn: fighting cancer with AI - Hylke Donker
(One of my summaries of the 2023 Dutch aiGrunn AI conference in Groningen, NL). What is cancer? According to wikipedia: abnormal cell growth with the potential to invade or spread to other parts of the body. That is what you can observe. Medically, there are several aspects of cancer: It prevents the cell from dying. It can grab more than usual resources. No sensitivity to the regular anti-growth signals. Etc. AI starts getting used in clinics. For instance for proton therapy: where to best apply the proton radiation. And in radiology: letting AI look at images to detect cancer. A good AI can out-perform doctors. Analysis of blood samples, trying to detect cancer based on the DNA samples in there. DNA mutations can also be detected, which is what he focuses on. Cancer is basically a "desease of the genome". DNA is made up of T, C, G and A sequences. Technically, it is perfectly feasable to "read" DNA. How do mutations occur? Exposure can leave "scars" in DNA. Damage can occur due to sunlight or smoking for instance. Specific sources result in specific kinds of damage: smoking has a "preference" for changing specific letters. With analysis, you can thus … -
aiGrunn: learntail, turn anything into a quiz using AI - Arjan Egges
(One of my summaries of the 2023 Dutch aiGrunn AI conference in Groningen, NL). Arjan is known for his programming videos. Alternative title: "the dark side of integrating a LLM (large language model) in your software". You run into several challenges. He illustrates it with https://www.learntail.com/ , something he helped build. It creates quizes from text to make the reader more active. What he used was the python library langchain to connect his app with a LLM. A handy trick: you can have it send extra format instructions to chatgpt based on a pydantic model. If it works, it works. But if you don't get proper json back, it crashes. Some more challenges: There is a limit on prompt length. If it gets too long, the LLM won't fully understand it anymore and ignore some of the instructions. A LLM is no human being. So "hard" or "easy" don't mean anything. You have to be more machine-explicit, like "quiz without jargon". The longest answer it provides is often the correct one. Because the data it has been trained on often has the longest one as the correct answer... Limits are hard to predict. The token limit is input + output, … -
aiGrunn: be a better developer with AI - Henry Bol
(One of my summaries of the 2023 Dutch aiGrunn AI conference in Groningen, NL). "Everybody" uses stackoverflow. Now lots of people use chatgpt (or chatgpt plus). Stackoverflow traffic has dropped by 50% in the last 1.5 year. So chatgpt can be your coding buddy. He really likes it for quickly getting something working (MVP). Like writing something that talks to a magento API (a webshop system). It would take him ages to figure it all out. Or he could ask chatgpt. He also thinks you don't need docstrings anymore: you can just ask chatgpt to explain a snippet of code for you. (Something I myself don't agree with, btw). (He demoed some chatgpt code generation of a sample website). What he learned: Good briefing and interaction is key. First tell it what you want before you start to code. Chatgpt sometimes loses track if the interaction goes on for too long. Read what it gives you, otherwise you won't know what it build for you. Watch out for the "cut-off time" of the chatgpt training set: perhaps newer versions of libraries don't work anymore with the generated code. Some dangers: You get lazy. You can get frustrated if you don't … -
aiGrunn: small and practical AI models for CO2 reduction in buildings - Bram de Wit
(One of my summaries of the 2023 Dutch aiGrunn AI conference in Groningen, NL). LLM models can be huge. Mind-boggling huge. But... we can also have fun with small models. He works a company that regulates climate installations in buildings (HVAC, heating, ventilation, air conditioning) via the cloud. Buildings use 30% of all energy worldwide. So improving how the HVAC installation is used has a big impact. A use case: normally you pre-heat rooms so that it is comfy when you arrive. But sometimes the sun quickly warms the room anyway shortly afterwards. Can you not conserve some energy without sacrificing too much comfort? You could calculate an optimal solution, but "just" measuring every individual room in combination with an AI. Technical setup: An "edge device" inside the building. An external API. The API stores the data in mysql (the room metadata) and influxdb (the timeseries). A user selects a room and a machine learning model type and a training data set (from historical data). The software creates a dataset from influxdb, trains the model (pytorch). The trained neural network goes to ONNX (open neural network exchange). The output is stored in minio (S3-compatible object store). Note: all this is … -
Django: Maybe disable PostgreSQL’s JIT to speed up many-joined queries
Here’s a write-up of an optimization I made in my client Silvr’s project. I ended up disabling a PostgreSQL feature called the JIT (Just-In-Time) compiler which was taking a long time for little benefit. This behaviour was observed on PostgreSQL 14, so things may have improved since. Although the version 15 and 16 release notes don’t seem to contain any relevant-looking changes. Okay, story time… I was looking at the project’s slowest tests and found one that took five seconds despite containing few lines of code. Profiling the test revealed a single slow query, which was also slow in production. I grabbed the query plan and fed it to pgMustard using the technique I previously blogged about): pgMustard reported that JIT compilation of the query was taking 99.7% of the 3217ms runtime. The five-star rating for this finding meant that it was ripe for optimization. But why was JIT compilation taking so long? The query used InheritanceManager from django-model-utils, which extends Django’s multi-table inheritance to return heterogenous subclasses of a base model: >>> Place.objects.select_subclasses() [<Library: Downtown Books>, <BookShop: Giovanni’s>] The generated query joins all subclasses’ tables. With many subclasses, that query has many joins. But each join only adds a … -
Contributing to Django - Sarah Boyce
Sarah Boyce on GitHub Django Triage & Review TeamDjangonaut.Space PyDev of the Week: Sarah Boyce Django Discord Channel Support the ShowLearnDjango.comButtonDjango News newsletter -
Database generated columns ⁽¹⁾: Django & SQLite
An introduction to database generated columns, using SQLite and the new GeneratedField added in Django 5.0. -
How to Kill the Django Development Server Without Ctrl+C
Let's say you're developing a Django project and you've lost track of the terminal window that ran your python manage.py runserver command. If you can't press Ctrl+C in the terminal, how do you stop the server? Finding the runserver Process First, we need to find the ID of the manage.py runserver process. On Linux, you can list all processes with the following command: ps aux To search the results, you can pipe the output of that command into the grep command: ps aux | grep manage.py If you want to search multiple words, enclose them in single quotes ' or double quotes ": ps aux | grep 'manage.py runserver' This should give you rows of table data such as: lance 12839 0.0 0.1 57068 49840 pts/25 S+ 07:11 0:00 python manage.py runserver lance 12840 23.0 0.2 435156 67752 pts/25 Sl+ 07:11 4:40 /home/lance/django-workout/.venv/bin/python manage.py runserver lance 23752 0.0 0.0 4040 1980 pts/30 S+ 07:31 0:00 grep --color=auto manage.py runserver This can be confusing because there are a few numbers here and I'm not sure what each number represents. To prepend a row of headers, we can run two commands back-to-back: ps aux | head --lines=1 && ps aux | grep … -
Adding Full Text Search to Your Django App with django-watson
Learn how to supercharge your Django app with full-text search using Django-Watson. Dive deep into Postgres magic and boost search functionality. -
Django News - 204 No Content - Django 4.2.7, 4.1.13, and 3.2.23 Security Release - Nov 3rd 2023
News Django security releases issued: 4.2.7, 4.1.13, and 3.2.23 A new security release for a potential denial of service vulnerability in UsernameField on Windows. As ever, the best security practice is to keep your Django version up to date with the latest release. djangoproject.com Python Software Foundation News: Announcing our new Community Communications Manager! The PSF's first Communications Manager will establish a PSF communications calendar, including annual messaging, newsletters, and blog posts. She will also partner with our Executive Director, Deb Nicholson, and other staffers to enhance our support for the Python community with various initiatives. blogspot.com Updates to Django Last week we had another massive 18 pull requests merged into Django by 13 different contributors - including 4 first time contributors! Congratulations to ksg, Leo Suarez, Izzy Hyman and CheesyPhoenix for having their first commit merged into Django - welcome on board! The System check framework docs now has a new section on writing integration tests: System check framework - Writing integration tests. I always love to see the documentation continue to improve to better serve the community! Coming in Django 5.1, there will be a new template tag {% query_string %} that allows changing a django.http.QueryDict instance for … -
Weeknotes (2023 week 44)
Weeknotes (2023 week 44)Unmaintained but maintained packages There’s a discussion going on in the django-mptt issue tracker about the maintenance state of django-mptt. I have marked the project as unmaintained in March 2021 and haven’t regretted this decision at all. I haven’t had to fix inconsistencies in the tree structure once since switching to django-tree-queries. And if that wasn’t enough, I get little but only warm and thankful feedback for the latter, so that’s extra nice. Despite marking django-mptt as unmaintained I seem to be doing a little bit of maintenance still. I’m still using it in old paid projects and so the things I do to make the package work for me is paid work. I’m not personally invested in the package anymore, so I’m able to tell people that there are absolutely no guarantees about the maintenance, and that feels good. Read the Docs I do understand why the .readthedocs.yaml file is now necessary. I wish that I wouldn’t have to do all the busywork of adding one to projects. I have just resubscribed to the Read the Docs Gold Membership which probably has expired at some point in the past. Read the Docs is excellent and everybody … -
Introducing djarter – An opinionated Django starter project
I have spent six years resisting the urge to make a starter template because (a) it locks you in to a particular development style, and (b) it prevents the repetition that promotes learning. But in the spirit of deploying high quality work, this repo contains a few best practices and useful tools for Django projects. These features would take a while to get set up from scratch, and might not be worth it for every project. But cloning this starter template can save you roughly a full day of work if you're planning to extend the built-in user authentication. Most importantly, though, no Bootstrap styling was used in the making of this template. Check out djarter on GitHub. -
Idempotent Jobs - Building SaaS with Python and Django #174
In this episode, we cleaned up the email sending job. I had to make some changes based on some discoveries that I made while researching how to track responses and associate the journal entries back to the user. While doing this clean up, we added a new Prompt model to make the email sending job idempotent for each day. -
Guide to setting up GeoDjango on Mac M1
There are a lot of guides on setting up GeoDjango and PostGIS. But most of them are outdated and doesn't work on Mac M1. In this article, let us look at how to set up GeoDjango on Mac M1/M2. Ensure you have already installed Postgres on your Mac. Install GeoDjango The default GDAL version available on brew fails to install on Mac M1. $ brew install gdal ==> cmake --build build Last 15 lines from /Users/chillaranand/Library/Logs/Homebrew/gdal/02.cmake: [javac] Compiling 82 source files to /tmp/gdal-20231029-31808-1wl9085/gdal-3.7.2/build/swig/java/build/classes [javac] warning: [options] bootstrap class path not set in conjunction with -source 7 [javac] error: Source option 7 is no longer supported. Use 8 or later. [javac] error: Target option 7 is no longer supported. Use 8 or later. BUILD FAILED /tmp/gdal-20231029-31808-1wl9085/gdal-3.7.2/swig/java/build.xml:25: Compile failed; see the compiler error output for details. Total time: 0 seconds gmake[2]: *** [swig/java/CMakeFiles/java_binding.dir/build.make:108: swig/java/gdal.jar] Error 1 gmake[2]: Leaving directory '/private/tmp/gdal-20231029-31808-1wl9085/gdal-3.7.2/build' gmake[1]: *** [CMakeFiles/Makefile2:9108: swig/java/CMakeFiles/java_binding.dir/all] Error 2 gmake[1]: Leaving directory '/private/tmp/gdal-20231029-31808-1wl9085/gdal-3.7.2/build' gmake: *** [Makefile:139: all] Error 2 We can use conda to install gdal. Create a new environment and install gdal in it. $ conda create -n geodjango python=3.9 $ conda install -c conda-forge gdal $ pip install django $ pip install psycopg2-binary … -
Django News - Django 5.0 beta 1 released and Django News Jobs - Oct 27th 2023
News Django 5.0 beta 1 released Django 5.0 beta 1 is now available. It represents the second stage in the 5.0 release cycle and is an opportunity for you to try out the changes coming in Django 5.0. djangoproject.com The Ruff Formatter: An extremely fast, Black-compatible Python formatter Ruff added a Black linter/formatter that is over 30x faster than existing tools while maintaining >99.9% compatibility with Black. If you haven't used Ruff before and are tired of waiting on your linting/formatting tools to run, now is a good time. astral.sh Updates to Django Last week we had a massive 16 pull requests merged into Django by 12 different contributors (you can tell there was a sprint) - including 5 first time contributors! Congratulations to Claire Pritchard, Lance Goyke, Chris Frisina, laserhyena and ontowhee for having their first commit merged into Django - welcome on board! This week there was a flurry of accessibility fixes around the Django admin. Including correcting the main content element (#34905), correcting HTML heading levels (#34911), fixing the size of back links (#34912), and adding borders in high contrast mode (#34913). We also added screenshot taking to Django's internal selenium test suite so that we can … -
μDjango (micro Django) 🧬
A single file Django micro project created for demonstration purposes to be used in the same way as other Python frameworks. -
Becoming a Django Fellow - Natalia Bidart
Djangonaut Space - 2024 Session 1 ApplicationWelcome our new Fellow - Natalia BidartEiffelDjango security releases issued: 4.2.6, 4.1.12, and 3.2.22 Django 5.0 Alpha Release NotesSupport the ShowLearnDjango.comButtonDjango News newsletter -
How to import requirements.txt into Poetry
First of all, congratulations on choosing Poetry for your Python project management. It’s a fantastic choice, and I hope that Poetry becomes the de facto standard. It’s time to bid farewell to the good old, barebones requirements.txt file, to move your dependencies over to Poetry, and let it handle everything—including … Read now -
Django News - 202 Accepted - Django, Django, Django - Oct 20th 2023
Django Software Foundation Announcing DSF Working Groups Previously, you more or less needed to be a board member to help; now, anyone can join — or form — a working group to further the DSF’s mission. djangoproject.com 2024 DSF Board Nominations Nominations are open for the 2024 Django Software Foundation Board of Directors. Anyone can apply. djangoproject.com Djangonaut Space now accepting applications for our next contributor mentorship cohort Apply for an 8-week group mentoring program where individuals will work self-paced in a semi-structured learning environment to contribute to Django. The deadline to apply is November 15th, 2023. djangoproject.com Nominations for 2023 Malcolm Tredinnick Memorial Prize An annual monetary prize awarded to the person who best exemplifies the spirit of Malcolm’s work in the Django community. djangoproject.com Updates to Django Last week we had 9 pull requests merged into Django by 6 different contributors - including 1 first time contributor! Congratulations to lufafajoshua for having their first commit merged into Django - welcome on board! This week mostly featured a number of small documentation and test improvements. Though a 14 year old bug also got closed! Previously a query string (which is used to pre-fill the form) would be lost when … -
Bullets of vaguely silvery hue
There is no single development, in either technology or management technique, which by itself promises even a single order-of-magnitude improvement within a decade in productivity, in reliability, in simplicity. If “The Mythical Man-Month” — or at least the popular distillation of it into a single pithy saying — is the most famous thing the late Fred Brooks ever wrote, then “No Silver Bullet”, the essay quoted above, must surely be the most infamous, or perhaps … Read full entry -
Customize the Django admin to differentiate environments
Customize the Django admin to differentiate environments We often have the same website running in different configurations: Once as a production site. Once as a place where editors update and preview the content. The content is later automatically (and maybe partially) transferred from this environment to the production environment. Once as a stage environment to stabilize the code. And maybe additional environments for local development. The Django admin panel mainly uses CSS variables for styling since theming support was introduced in Django 3.2 (by yours truly with a lot of help from others). This makes it simple and fun to customize the colors of all interface elements in a straightforward way without having to write loads of CSS. If you have a ENVIRONMENT context variable available (as we do) you could add the following template as admin/base.html to your project, giving you a red color scheme for the production environment (to discourage people from updating content) and a nice scheme for the preproduction environment which clearly deviates from the standard color scheme used everywhere else: {% block extrahead %} {{ block.super }} <style> #site-name::after { content: " ({{ ENVIRONMENT }})"; font-size: 60%; } </style> {% if ENVIRONMENT == 'production' %} … -
Email Round Trip - Building SaaS with Python and Django #173
In this episode, we took advantage of having all the DNS configuration complete and tried to find the path to connect the outgoing prompt email to the incoming journal entry from a user. We did this with some old-school print debugging and logging on production to see exactly what data is provided to the receiver webhook. -
Weeknotes (2023 week 42)
Weeknotes (2023 week 42)Vacation in Italy We have spent a wonderful family week in Italy. The voyage by train was very comfortable and we had a great time there. I have lived close to lakes all my life but the sea is always something else. Now I enjoy the cold temperatures of fall. Going back (forward) to GitJournal I have tried several note taking apps but I’m now back using GitJournal with a Git repository filled with Markdown notes. It works well enough. I just wish that there was a way to make notes more distinguishable and I wish that the editor was more forgiving when encountering badly formatted checklists. Analog blogging I have long wanted to write about our switch from Slack to Discord. I have started to write this post with pen and paper. I find that I think better when using pen and paper than when using the computer keyboard. One factor is certainly that the computer offers more distractions, but I suspect that another, more important factor is that as a fast typist the fingers and the thinking are always getting out of step, and this happens less when using a slower method of writing. This … -
Boost Your DX bundle deal
I released Boost Your Git DX nearly two weeks ago. It’s the second in my “Boost Your DX” series, following last year’s Boost Your Django DX. Both books aim to improve your development experience with their respective tool. Today I’m happy to announce the bundle deal for the pair of books. Check out either of the two books, enter your details and click “pay”, and you’ll be offered a $10 discount on the second one: If both topics interest you, I hope this deal makes it worth your while to pick up the two books together. This offer does not apply to team licenses. And unfortunately, the discount doesn’t stack with the regional one for those in lower-income countries, due to a limitation on Gumroad. I hope they will add support in the future. Find the deal by going through the checkout process with either title: Boost Your Django DX Boost Your Git DX May you continually boost your developer experience, —Adam -
Django News - 201 Created - Last call for DjangoCon US 2023 tickets! - Oct 13th 2023
News Last call for DjangoCon US 2023 tickets! DjangoCon US kicks off this Monday, October 16th - 18th. Online tickets are still on sale! If you are attending this year, Jeff, Will, and Catherine will be there. Say hello in person or virtually. ti.to Help us make the djangoproject.com website better Did you know a redesign is happening to the main djangoproject.com website? Please fill out this concise survey to share your thoughts on improving it. google.com Updates to Django Last week we had 14 pull requests merged into Django by 10 different contributors - including 4 first time contributors! Congratulations to ume, Pieter Cardillo Kwok, Denis Rouzaud and Faishal manzar for having their first commits merged into Django - welcome on board! Features for Django 5.1 are already being accepted! 5.1 will allow template tags to set extra data for templates (#34883 and release note) and assertContains(), assertNotContains(), and assertInHTML() assertions will now add haystacks to assertion error messages (#34657 and release note). Next week is DjangoCon US! There are a number of ways you can engage in the conference virtually including get involved in the sprints! You can read about this on the Django forum and sign up. …