Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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. … -
Practical AI: HuggingFace Transformers and Diffusers for Beginners
This presentation provides a straightforward overview of the HuggingFace Transformers and Diffusers libraries. Aimed at those without a deep understanding of AI or ML, we’ll focus on practical, hands-on applications. We conclude by setting up a Flask app that generates AI images, demonstrating how these tools can be used to create useful applications. -
The validation evolution: Pydantic V2tronger - Marcelo Trylesinski
(One of my summaries of the 2023 Dutch pythonconferentie python meeting in Utrecht, NL). Pydantic is a data validation library. It uses/extends python type hints to work during runtime instead of statically. Pydantic recently went from version 1 to 2. One of the changes was to split pydantic in a few packages. Pydantic core is now partially written in Rust! Some other changes: In Version 1 you could add a Config class inside your model class, but it was sensitive to spelling mistakes. Now they use a model_config attribute that prevents errors. As they were breaking the API anyway, they took the opportunity to change lots of names to make them clearer. @validator is now @field_validator which accepts extra attributes, for instance for doing a special check before or after the regular validation. "After" validations are handy as you can run a check after pydaantic has ensured it was the correct type, this prevents lots of error handling in your custom validation. BaseSettings is now in a separate python package as it got a bit too big. Several __something__ methods were changed to give you more options to change pydantic's behaviour. Some performance tips (see also https://docs.pydantic.dev/latest/concepts/performance/ ): Use model_validate_json() … -
When to refactor your code into generators and how - Jan-Hein Bührman
(One of my summaries of the 2023 Dutch pythonconferentie python meeting in Utrecht, NL). See https://github.com/jhbuhrman/refactor-into-generators for the presentation with the code examples, as I cannot type in those code examples quickly enough into this summary :-) You don't want to repeat yourself. DRY. His example code showed four different kinds of fibionacci functions what just seemed to beg for some refactoring. Splitting out common parts. But turning it into one function with some if/else was possible, but it looked ugly and inelegant. Especially when you have loops, it often helps to look at your code a bit more conceptually. Often there is a "producing" part and a "consuming" part. Can you split it there, especially with a generator function? A generator function is a function that uses one or more yield statements. You can use such a generator with .next() or in a loop. You can go a step further with python's build-in itertools package. There is also an extra package more-itertools. Some examples: itertools.takewhile(predicate, iterable): continue until the predicate function returns true. Handy to stop when a condition is reached. There's also .dropwhile(). itertools.islice(iterable, start, stop, step): a bit like regular list slicing. more_itertools.one() return the first item … -
Diving into event-driven architectures - Marc-André Lemburg
(One of my summaries of the 2023 Dutch pythonconferentie python meeting in Utrecht, NL). Marc-André has been involved with python already since 1994. If you want to implement something you want to see grow, it should be scalable (vertically and horizontally). Easy to adapt, easy to maintain. Prepared for the enterprise. You have to keep it in mind from the beginning. Also: Have good failure modes. Everything will fail at some point: handle it elegantly. Integrate observability. If something fails you need to know what happened. Automate governance. You might not think about this from day one, but if you want to grow... There are two well-known synchronous archtectures: REST and the lesser known GraphQL. REST has good frontend support. Every backend can "do" it. GraphQL has the advantage that it simplifies querying new data. It is just more flexible. But performance is a problem. Regular REST also isn't necessarily speedy. EDA, event-driven architectures, could be a solution. Asynchronous. You can combine it with REST/GraphQL. The asynchronous nature ensures it scales well. It also promotes loose coupling. The main concept is event driven communication. You pass along messages. You produce and consume without a direct connection. There's always a broker … -
Python and freedom and bias - Laís Carvalho
(One of my summaries of the 2023 Dutch pythonconferentie python meeting in Utrecht, NL). She showed "the zen of python": >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! She herself wondered whether she fully understood those. Are they suggestions? Aphorisms? The law? She took the book "Gödel, Escher, Bach". Mentioned in there, are the three layers of any message: Frame message. … -
The IQ of AI: measuring intelligence in AI models - Jodie Burchell
(One of my summaries of the 2023 Dutch pythonconferentie python meeting in Utrecht, NL). Jodie wants to look at large language models (like chatgpt), which went into full-on hype mode this year. Let's look at some historical examples of what people have thought to be artificial intelligence. At the first demonstration of a remote contolled boat, people didn't know what happened. Was this artificial intelligence? In 1997, Kasparov lost the chess match to Deep Blue. The basic problem was that the computer did a totally unexpected move ("real intelligence") in the first match that threw Kasparov off track and caused him to make mistakes in confusion. Years later a google engineer thought an AI had come to life, It responded like a nine year old. He wanted legal protection for the AI. (He was fired). Now chatGPT: people think it displays real artificial general intelligence. But what is the reality? Can we look at it more scientifically? A well known article ("sparks of artifical general intelligence") claims to use categories from an older article to rank it: reasoning, planning, problem solving, abstract thinking, comprehending complex ideas, learning quickly and from experience. Only... Jodie has lots of experience in psychology and … -
The magic of self: how python inserts self into methods - Sebastiaan Zeeff
(One of my summaries of the 2023 Dutch pythonconferentie python meeting in Utrecht, NL). There's deep magic in python. Some of it is really hard to understand. Guido van Rossum: "from day one, there was deep magic hiding in some places, designed to quietly help users". Sebastiaan is going to show us a nice example of python magic: how "self" gets injected into method calls on a class: class Guitar: def __init__(self, name): self.name = name def play_note(self, note): print(f"{self.name} plays {note}") You can instantiate a guitar and call my_guitar.play_note("B") on it. With just the note as a parameter. But where is the self coming from? Somehow your instance of the Guitar class is magically inserted. Note: self is not a magical keyword. You can give it a different name and it will still work (though your code will be unreadable and people will hate you). Everything in python is an object. A class is an object (an instantiation of Type). A method inside a class is a regular function object. Plus it is also added with the name of the function as an attribute to the class (the namespace of the class). If you call my_guitar.play_note("B"), your my_guitar is … -
PyCharm's Year of Django - Paul Everitt
PyCharm JetBrains JetBrains Fleethttps://htmx.org/essays/right-click-view-source/ Django Chat #88: PyCharm with Paul Everitt & Aleksei Kniazev2023 Django Developers Survey django-microframework Badass: Making Users Awesome book Django Views the Right Way by Luke Plant Django Testing Tutorial The #ViewSource Affordance Support the ShowLearnDjango.comButtonDjango News newsletter -
Customizing Django 404 and 500 Error Pages
For any web application, users will inevitably navigate to error pages like 404 (Page Not Found) or 500 (Server Error). Django ships with default error pages for both, but if … -
My appearance on the Django Chat podcast
<![CDATA[ My appearance on the Django Chat podcast I was honored to be a guest on the Django Chat podcast recently! It was great fun, even though I was a bit nervous speaking on a podcast since English is not my first language, and I don’t speak often. I have been following Carlton and Will online for a long time and read Will’s books on Django, so it was great to meet both via video for the podcast. We talked about "mezcla" of things, including my background, switching to Django, using Django Rest Framework for SwitchBuddy, and also iOS stuff like new versions, API changes, and similar. You can find the episode on the official Django Chat website or in any of the podcast players you might use. ]] -
Django News - 200 OK - Django Security Releases: 4.2.6, 4.1.12, and 3.2.22 - Oct 6th 2023
News Django security releases issued: 4.2.6, 4.1.12, and 3.2.22 Posted by Natalia Bidart on October 4, 2023 djangoproject.com Python Release Python 3.12.0 Python 3.12.0 is the newest major release of the Python programming language, and it contains many new features and optimizations. python.org Python Insider: Python 3.11.6 is now available Python 3.11.6 is the newest major release of the Python programming language, and it contains many new features and optimizations. blogspot.com Updates to Django Last week we had 11 pull requests merged into Django by 6 different contributors - including 1 first time contributor! Congratulations to Dan Jacob for having their first commit merged into Django - welcome on board! Any bugs found in the new features of 5.0 are considered "Release blockers". We had 3 release blockers resolved last week (#34849, #34877, #34878) which were discovered by Mariusz Felisiak, Paolo Melchiorre and Dan Jacob. I want to thank each of you for testing 5.0 and uncovering these issues! Testing 5.0 is a great way to contribute to this release and might even lead to your first commit to Django! There are even a couple of 5.0 Testathons planned as community events - sign up here if you're free: https://forms.gle/eqXBtCTa8V5KrL9h9 … -
How to Stop macOS from Stealing Focus after Switching Apps Across Desktops
For years, I’ve had a macOS bug that occurred randomly and that I could only fix by rebooting or logging out. The Internet is full of similar problems, but I never found a solution to mine, and my pleas for help on Twitter went unanswered. Now, I have found a workaround myself. -
Django Fixtures Tutorial: How to use dumpdata and loaddata
A [fixture](https://docs.djangoproject.com/en/4.2/topics/db/fixtures/) is a collection of data that can be dumped or loaded into a Django database. It is serialized into a text-based format such as JSON or XML and … -
DNS Strikes Back - Building SaaS with Python and Django #172
In this episode, we returned to our DNS configuration from the previous stream and worked on testing email from end to end on the production site. On the stream, we spent a lot of time looking through SendGrid documentation, digging into layers of DNS, and troubleshooting the challenges that can arise when getting a site online. -
Django and iOS - Filip Němeček
Personal siteBlog MastodonDjango FeedsDjango BlogsImpressKitSwitch Buddy Gaming Buddy Support the ShowLearnDjango.comButtonDjango News newsletter -
Django Fixtures Tutorial: How to use dumpdata and loaddata
A [fixture](https://docs.djangoproject.com/en/4.2/topics/db/fixtures/) is a collection of data that can be dumped or loaded into a Django database. It is serialized into a text-based format such as JSON or XML and … -
Weeknotes (2023 week 40)
Weeknotes (2023 week 40)More work on hosting several websites from a single Django application server using feincms3-sites I have mentioned feincms3-sites last week in my last weeknotes entry; I have again given this package a lot of attention in the last days, so another update is in order. It is now possible to override the list of languages available on each site. That’s especially useful for an upcoming campaign site where the umbrella group’s site is available in three languages, but (most?) individual group sites (hosted on subdomains) will only have a subset of languages. Since I live in a country with four national languages (english isn’t one of them, but is spoken by many!) supporting more than one language, or even many languages is totally commonplace. It’s great that Django has good support for internationalization. For the sake of an example, I have the following sites: example.com: The default. The host has to match exactly. subdomain.example.com: One individual group’s site. The host has to match the regex ^subdomain\. (sorry, I actually do like regexes). Overriding configured hosts for local development One thing which always annoyed me when using django.contrib.sites was that “just” pulling the database from production to the … -
Django Best Practices: Docker
[Docker](https://www.docker.com/) is a very popular tool for managing Django projects. Many professional developers use it but I find it is still confusing to many newcomers. In this post I'll attempt … -
Django Best Practices: Imports
Imports are an inevitable part of Python and Django development. [Pep8](https://pep8.org/#imports), which is the official style guide for Python, recommends imports be placed at the top of the file, on … -
Django Best Practices: Models
Properly defining database models is arguably __the__ most important part of a new project, however Django provides us with tremendous flexibility around *how* we structure our models. There _is_ an … -
Django Best Practices: Security
Django is a mature, battle-tested web framework with a well deserved reputation for security over the past 15+ years.However the internet remains a dangerous place and web security is an …