Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Office Hours
Ask me professional questions in a small group Zoom meeting setting. Past topics of discussion have included: Code review! Attendees can share code with me, unless given permission I won't share with other attendees even though I will comment verbally on it. Project design and architecture Resolving bugs in code Career advice Managing tough job situations Resume and portfolio evaluation Next session is 10AM to Noon PST / 5PM-7PM UTC on Wednesday, September 2nd, 2020. Sign up now! -
Django Testing Tutorial
Testing is an important but often neglected part of any Django project. In this tutorial we'll review testing best practices and example code that can be applied to any Django … -
Authenticating Django PostgreSQL User in Multiple Docker Compose Environments
I’ve been building a Django project template using Docker Compose, PostgreSQL, and Nginx. Docker is a definite weak point for me, so I used an article from Michael Herman to set it up: Dockerizing Django with Postgres, Gunicorn, and Nginx. I made some additions to that tutorial – custom user model, re-organized config files – but I kept running into the same issue… Django Can’t Connect to Postgres When switching between development and production environments, Django could not connect to my postgres database: docker-compose up -d --build docker-compose exec web python manage.py migrate django.db.utils.OperationalError: FATAL: password authentication failed for user "" I had set up the same username for both the development and the production environment postgres services, but the passwords were different. For some reason, Docker Compose wasn’t re-configuring postgres with the new information when I switched containers. Temporary Fix I was able to avoid the problem with some help from the testdriven.io tutorial mentioned above: docker-compose down -v docker-compose -f docker-compose.prod.yml down -v The -v flag brings down all volumes, i.e. my postgres database. Then, when bringing the containers back up, Docker Compose would say, “I don’t have any volume called postgres_data. I better make one!” This would … -
Django and the N+1 Queries Problem
This is a cross-post from the Scout APM blog, where I occasionally write. I also maintain the Scout Python integration. The N+1 Queries Problem is a perennial database performance issue. It affects many ORM’s and custom SQL code, and Django’s ORM is not immune either. In this post, we’ll examine what the N+1 Queries Problem looks like in Django, some tools for fixing it, and most importantly some tools for detecting it. Naturally Scout is one of those tools, with its built-in N+1 Insights tool. We’ll cover: What Is the N+1 Queries Problem? N+1 Queries 2N+1 Queries NM+N+1 Queries Tools to Fix the N+1 Queries Problem select_related() prefetch_related() django-auto-prefetch Tools for Finding N+1 Query Problems django-debug-toolbar nplusone Scout APM What Is the N+1 Queries Problem? In a nutshell: code that loops over a list of results from one query, and then performs another query per result. Let’s look at a basic example and a couple of its natural extensions. N+1 Queries Say we had this code: books = Book.objects.order_by("title") for book in books: print(book.title, "by", book.author.name) This code uses print() for simplicity, but the problem exists in all other ways data might be accessed, such as in templates or views … -
Introducing Tight.ai - My First Desktop App
I just released a production-g... -
Django Best Practices: Referencing the User Model
Django has a powerful, built-in [user authentication system](https://docs.djangoproject.com/en/4.0/topics/auth/default/) that makes it quick and easy to add [login, logout, and signup functionality](https://learndjango.com/tutorials/django-login-and-logout-tutorial) to a website. But how should a Django developer … -
Flask Stripe Tutorial
This tutorial looks at how to quickly add Stripe to a Flask app in order to accept payments. -
Django News - Django Technical Board Election - Aug 28th 2020
News Announcement of Technical Board Election Registration There is an upcoming Django Technical Board election. All current DSF Members are automatically registered for this election. If you are not a DSF Member but would like to vote in this election there is a form to fill out. djangoproject.com Black 20.8b1 Pre-release of the latest version of Black, the opinionated Python formatter. github.com Wagtail 2.10.1 release notes Bugfix release for the lastest major Wagtail version. wagtail.io GitHub Changelog: Set the default branch for newly-created repositories GitHub now allows you to change your default branch name for newly-created repositories. PSA: On October 1, 2020, GitHub is changing the default from master to main. github.blog Events PyCon AU / DjangoCon AU 2020 - Sept. 4th – 6th, 2020 PyConline AU and DjangoCon AU are one week away! pycon.org.au Articles Administer All the Things The next in a series by Matt Layman, this in-depth tutorial focuses on the Django admin. mattlayman.com Python Tools for Managing Virtual Environments A comprehensive look at the multiple ways to manage Python virtual environments. dev.to Test Elasticsearch in Django Without Mocking Use Django and pytest to test Elasticsearch without mocking. yanglinzhao.com Tutorials Deploying a Production-ready Django app on AWS … -
Authenticating Google Client Library for a Django Application
Recently I was tasked with integrating Google Sheets with Django. It was necessary for a row to be added to a Google Sheet on completion of a user action. Having no experience with interacting with Google Sheets programmatically, a quick search found me the Google Sheets API V4 Python Quickstart Guide. Remember: I needed to append a row a Google sheet on behalf of the application NOT the user. OAuth I followed the quickstart guide and was able to create a functioning application that was able to add a row to Google Sheets. However as I simply followed the Quickstart guide I only experienced the OAuth workflow. This meant I was required to sign in, in order to get my application to make changed to the Google Sheet. This was not viable in a production environment. OAuth would only make sense if I was manipulating Google Sheets on a users behalf. It would be ok for a user to be shown a Google login page to complete and on completion their access token to be stored on the server for authentication to the API. I haven’t provided any code examples for this because Google have already provided this here. API … -
Authenticating Google Client Library for a Django Application
Recently I was tasked with integrating Google Sheets with Django. It was necessary for a row to be added to a Google Sheet on completion of a user action. Having no experience with interacting with Google Sheets programmatically, a quick search found me the Google Sheets API V4 Python Quickstart Guide. Remember: I needed to append a row a Google sheet on behalf of the application NOT the user. OAuth I followed the quickstart guide and was able to create a functioning application that was able to add a row to Google Sheets. However as I simply followed the Quickstart guide I only experienced the OAuth workflow. This meant I was required to sign in, in order to get my application to make changed to the Google Sheet. This was not viable in a production environment. OAuth would only make sense if I was manipulating Google Sheets on a users behalf. It would be ok for a user to be shown a Google login page to complete and on completion their access token to be stored on the server for authentication to the API. I haven’t provided any code examples for this because Google have already provided this here. API … -
Predicting The Future - Building SaaS #70
In this episode, we worked on two issues. The first issue was fixing incorrect projected completion dates of tasks. We used test driven development to reveal the bug and work on the fix. The second issue add some extra data to display on a page. We picked a couple of tasks at random to fix for this stream session. The first issue related to the course view when paired with what the student’s actions. -
Python Dependency Injection
This post looks at how to use dependency injection to decouple and improve the design of a Python application. -
Mirrors migrated out of bitbucket
As you are probably aware, bitbucket is dead. At least the original bitbucket as we knew it, the leader in mercurial hosting. They no longer host mercurial repositories, so I had to move my kernel and Django mirrors. They are now hosted on my own heptapod instance, at the following URL: https://hg.freehackers.org/ I did the […] -
Administer All The Things
In the previous Understand Django article, we used models to see how Django stores data in a relational database. We covered all the tools to bring your data to life in your application. In this article, we will focus on the built-in tools that Django provides to help us manage that data. What Is The Django Admin? When you run an application, you’ll find data that needs special attention. Maybe you’re creating a blog and need to create and edit tags or categories. -
How to configure Environment Specific settings in Python Django Framework?
There are certain configurations in your settings.py such as DEBUG, STATIC_URL, DATABASES, SECRET_KEY, ALLOWED_HOSTS, etc. These settings are actually the ones that you need to look after while deploying to the production environment. Whenever your application goes live, you shouldn't display your debug logs, or error messages on the browsers. This will make your application vulnerable. Also you might want to put different secret keys. For these reasons, we need environment-specific settings. In this tutorial, I will be creating different settings for local, development, and production environment. -
Django News - Issue 37 - Aug 21st 2020
News GSOD 2020 Project - Django Internals / Mentorship With Google Season of Docs (GSOD) kicking off, Gabby Precious wants to know if you have any specific challenges with Django's contribution documentation? djangoproject.com Python Insider: Python 3.7.9 and 3.6.12 security updates now available The lastest security fix rollups for Python 3.7 and Python 3.6 are now available. blogspot.com Tailwind CSS v1.7.0 (1.7.1, 1.7.2, and 1.7.3) The Tailwind CSS v1.7.x release adds a bunch of new features ranging from gradients, background-clip, gap, contents display, font-size letter-spacing, and more interesting new features. tailwindcss.com Events DjangoCon Australia 2020: Schedule live and tickets on sale 🎟️ Tickets are on sale and the schedule has been released for the 8th DjangoCon AU. djangoproject.com Articles Running Django Tests in Github Actions A nice, concise introduction to how to use GitHub Actions as a CI platform for testing your Django code. banagale.com A deep dive into the official Docker image for Python Itamar Turner-Trauring Itamar does an excellent job of deconstructing the official Python image for Docker and gives some sound advice and tips along the way. pythonspeed.com Why Internationalization and Localization matters by Nicolle Cysneiros A practical and concise guide to Internationalization and Localization using Python … -
Create icns Icons for macOS Apps.
I've been working a lot with E... -
We've released a new python book!
That's right, we've released Practical Python Projects, a book of twelve bite-sized weekend projects to enhance your Python knowledge! And the first 25 people to use code "ppp-feldroy-blog" will get 15% off the purchase price! Practical Python Projects is a book authored by Yasoob Khalid. We've admired Yasoob's code and writing for years. The level of his work is set at the level of quality the Feldroy team constantly strive to meet. In fact, you can read for free Yasoob's popular and free first book, Intermediate Python. This book does more than just walk readers through code, it teaches how the research was done for each project. Building off this research, each chapter ends with a "next steps" section guiding the reader towards making the project unique to themselves. Want to know what we think of Practical Python Projects? "A favorite way to for developers to grow their programming skills is by building small practical projects. Yasoob's book embraces this idea, taking the reader on a tour of over a dozen projects, reinforcing research and coding skills along the way. His technical acumen combines with unbridled enthusiasm to make for a delightful and informative book." -- Daniel Feldroy, co-author of … -
Polishing and Usability - Building SaaS #69
In this episode, we polished some parts of the application. Now that my first customer is using the app regularly, the feedback is coming in rapidly. We worked to fix some of the issues that she found. The first issue that I tackled dealt with ambiguity about a course’s relationship to a school year on the course’s detail page. I fixed this issue by displaying the grade level on the course page to provide all the details. -
A Guide to Django Web Development for your Business
It’s frustrating to decide the technology stack for your product – unless you are an experienced CTO. Whether to choose Ruby on Rails or Flask or Django web development or anything else – it’s challenging. Even when you decide on a framework, there are various problems. Trusting the framework for fulfilling your requirements is an […] The post A Guide to Django Web Development for your Business appeared first on BoTree Technologies. -
Async Views in Django 3.1
This post looks at how to get started with Django's new asynchronous views. -
Creating a Low Cost Managed Kubernetes Cluster for Personal Development using Terraform
Kubernetes is an open-source system that's popular amongst developers. It automatically deploys, scales, and manages containerized applications. Yet for those working outside of the traditional startup or corporate setting, Kubernetes can be CPU and memory-intensive, disincentivizing developers from using a strategically beneficial tool. We'll highlight some of the constraints posed by using Kubernetes and offer a series of low-cost, practically-beneficial solution: a Google Kubernetes Engine cluster deployed and managed with Terraform. Want to run Kubernetes locally? [Kind](https://github.com/kubernetes-sigs/kind) is a tool that’s remarkably easy to set up and experiment with. It even supports multi-node clusters! However, the abundance of pods and nodes can be CPU/memory intensive. Another potential roadblock is the popularity of managed Kubernetes solutions: since many companies go this route, you'd want to have some experience with a managed solution. Gaining this experience in a non-corporate setting means personally using Managed Kubernetes –– a costly investment for a solo developer. The baseline cost for an EKS cluster is $72 per month, with similar pricing for regional AKS and GKE clusters. Add in additional node costs for running your workloads and before you know it, you’re running a hefty monthly bill. Here are some potential ways to address computer and … -
Django News - New Wagtail Release and results from the Django Developers Survey 2020 - Aug 14th 2020
News Wagtail 2.10 Released A major new release with a configurable workflow system, full page and site history, a design overhaul of the page editor, Django 3.1 support, search query expressions, bulk redirect importing, and more. wagtail.io HTTPX 0.14.0 Released A major new release in HTTPX, the async successor to Requests. github.com Django Developers Survey 2020 Results from the Django Developers Survey 2020 were released. google.com Python Insider: Python 3.9.0rc1 is now available Python 3.9.0 is almost ready. This release, 3.9.0rc1, is the penultimate release preview. blogspot.com Deadline to nominate someone for Quarter 3 consideration is August 20, 2020 If you want to recommend someone to be a PSF Fellow, you have until August 20th to do so. python.org Events Django Boston August 2020 Virtual Event Benjamin "Zags" Zagorsky will present "Rapid Prototyping in Django," a distilled set of lessons and recommendations for how to build a functional Django website in 2 days and not regret it later. meetup.com Articles Django Views — The Right Way An opinionated guide on how to write views in Django. github.io Using Postgres JSONB Fields in Django In-depth look at using Postgres JSONFields in Django. pganalyze.com Customize the Django Admin With Python A guide … -
Deploying Django to AWS ECS with Terraform
In this tutorial, we'll look at how to deploy a Django app to AWS ECS with Terraform. -
Rendering Calendars - Building SaaS #68
In this episode, I worked on rendering a calendar of important events in a school year. We built out the appropriate data structures, and I wrote some new model methods and added tests. On the last stream, I created a new model to track breaks in the school year. The app now shows the calendar for the school year, and I want to display the breaks on the calendar. Before digging too far into the code, I provided my thoughts about using Docker for development from a question that came from the chat.