Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Adding two factor authentication to Django admin
As my dissatisfaction with WordPress grew, I did the only Reasonable Thing(tm) and decided to roll out my own CMS again. Which means I do not only have the joy of building a tool exactly fitting my needs, but I also have to build some of the functionality I would expect every production-ready system to provide. Account security in Django’s contrib.auth and contrib.admin package did not change a lot over the last decade, but in 2020 I expect some basic functionality from every system, like two factor authentication. As 2FA is missing in Djangos admin package, what is the Reasonable Decision(tm)? To add it myself, of course. You might see a trend of “reasonable yak shaving” here. (A small side note if you are working on a SaaS or web app right now: Account security is not a “premium feature” or a feature your users should have to pay for. It is basic functionality you should always provide to anyone, no matter if they are free or paid users, no matter which plan. And now back to our scheduled program!) This article assumes you have some familiarity with Python and Django; at least enough to create a new application, inherit … -
Adding two factor authentication to Django admin
As my dissatisfaction with WordPress grew, I did the only Reasonable Thing(tm) and decided to roll out my own CMS again. Which means I do not only have the joy of building a tool exactly fitting my needs, but I also have to build some of the functionality I would expect every production-ready system to provide. Account security in Django's contrib.auth and contrib.admin package did not change a lot over the last decade, but in 2020 I expect some basic functionality from every system, like two factor authentication. As 2FA is missing in Djangos admin package, what is the Reasonable Decision(tm)? To add it myself, of course. You might see a trend of "reasonable yak shaving" here. (A small side note if you are working on a SaaS or web app right now: Account security is not a "premium feature" or a feature your users should have to pay for. It is basic functionality you should always provide to anyone, no matter if they are free or paid users, no matter which plan. And now back to our scheduled program!) This article assumes you have some familiarity with Python and Django; at least enough to create a new application, inherit … -
Django JSONField attributes in admin filter
Django provides a JSONField which is useful to store JSON data and query on it. However, this is supported by PostgreSQL only. If you want to use JSONField with MySQL or MariaDB, you can use django-mysql-json-field. But in this post, we’ll be using inbuilt JSONField. Django provides us with a way to query on JSONfield but you can’t directly use JSONField’s attributes on admin as filters. In this post, I’ll be creating a Filter class for JSONField that can be used to create filters on the admin page. Let’s start with a simple model that has 1 JSONField. class MyModel(models.Model): jsonfield = JSONField() # few more fields... Populate this field with below data, we’ll use this data throughout the post as a reference. { "name": "Gaurav", "company": "pyscoop", "address": { "city": "Jaipur", "country": {"name": "India", "code": "IN"} } } Now suppose you want to create filters for JSONField properties/keys, for e.g. consider the above data, we want to show filters for company and city, something like below- class MyModelAdmin(admin.ModelAdmin): list_filter = ["jsonfield__company", "jsonfield__address__city"] But as expected, this will raise an error, we can’t use JSON field attributes for filtering like this. To support that we need to extend the inbuilt filter class. … -
Store Data With Models
In the previous Understand Django article, we encountered forms and how forms allow your application to receive data from users who use your site. In this article, you’ll see how to take that data and store it into a database so that your application can use that data or display it later. Setting Up Let’s figure out where your data goes before getting deep into how to work with it. -
Adding two factor authentication to Django admin
Adding two factor authentication to Django admin As my dissatisfaction with WordPress grew, I did the only Reasonable Thing™ and decided to roll out my own CMS again. Which means I do not only have the joy of building a tool exactly fitting my needs, but I also have to build some of the functionality I would expect every production-ready system to provide. Account security in Django’s contrib.auth and contrib.admin package did not change a lot over the last decade, but in 2020 I expect some basic functionality from every system, like two factor authentication. As 2FA is missing in Djangos admin package, what is the Reasonable Decision™? To add it myself, of course. You might see a trend of “reasonable yak shaving” here. (A small side note if you are working on a SaaS or web app right now: Account security is not a “premium feature” or a feature your users should have to pay for. It is basic functionality you should always provide to anyone, no matter if they are free or paid users, no matter which plan. And now back to our scheduled program!) This article assumes you have some familiarity with Python and Django; at least … -
Learning Wagtail - Kalob Taulein
LearnWagtail.comCoding for EverybodyKalob’s Udemy coursesawesome-wagtailThis Week in WagtailDjango Search TutorialHow to Get Hired as a Django DeveloperWagtail Slack channelFrom Burn-Out to $100M in ARR with Jason Cohen of WP Engine -
Securing a Containerized Django Application with Let's Encrypt
In this tutorial, we'll look at how to secure a containerized Django app running behind an HTTPS Nginx proxy with Let's Encrypt SSL certificates. -
How to search Google without using Google, the self-hosted way
Hello everyone! Last week I was talking with a friend and he was complaining about how Google knows everything about us, so I took the chance to recommend some degoogled alternatives: I sent him my blog, recommended DuckDuckGo, Nextcloud, Protonmail, etc. He really liked my suggestions and promised to try DuckDuckGo. A couple of days later he came to me a little defeated, because he didn’t like the search results on DuckDuckGo and felt bad going back to Google. So that got me thinking: Are there some degoogled search engines that use Google as the backend but respect our privacy? So I went looking and found a couple of really interesting options. Startpage.com According to their Wikipedia: Startpage is a web search engine that highlights privacy as its distinguishing feature. Previously, it was known as the metasearch engine Ixquick … On 7 July 2009, Ixquick launched Startpage.com to offer its service at a URL that is both easier to remember and spell. In contrast to Ixquick.eu, Startpage.com fetches results from the Google search engine. This is done without saving user IP addresses or giving any personal user information to Google’s servers. and their own website: You can’t beat Google when … -
How to search Google without using Google, the self-hosted way
Hello everyone! Last week I was talking with a friend and he was complaining about how Google knows everything about us, so I took the chance to recommend some degoogled alternatives: I sent him my blog, recommended DuckDuckGo, Nextcloud, Protonmail, etc. He really liked my suggestions and promised to try DuckDuckGo. A couple of days later he came to me a little defeated, because he didn’t like the search results on DuckDuckGo and felt bad going back to Google. So that got me thinking: Are there some degoogled search engines that use Google as the backend but respect our privacy? So I went looking and found a couple of really interesting options. Startpage.com According to their Wikipedia: Startpage is a web search engine that highlights privacy as its distinguishing feature. Previously, it was known as the metasearch engine Ixquick … On 7 July 2009, Ixquick launched Startpage.com to offer its service at a URL that is both easier to remember and spell. In contrast to Ixquick.eu, Startpage.com fetches results from the Google search engine. This is done without saving user IP addresses or giving any personal user information to Google’s servers. and their own website: You can’t beat Google when … -
Setup Django on Mac in 2020
There are many ways to setup Django on MacOS. Here is how to get started while keeping the flexibility to have projects in different versions of Django and different versions of Python too. -
Setup Django on Mac in 2020
There are many ways to setup Django on MacOS. Here is how to get started while keeping the flexibility to have projects in different versions of Django and different versions of Python too. -
How to Learn Django (2023)
__Note__: I gave a version of this tutorial at DjangoCon US 2022. You can see the video here: <iframe width="738" height="417" src="https://www.youtube.com/embed/rIt0uj8TaKg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" … -
How to pull production data into your local Postgres database
Sometimes you want to write a feature for your Django app that requires a lot of structured data that already exists in production. This happened to me recently: I needed to create a reporting tool for internal business users. The problem was that I didn't have much data in my … -
Working with Celery and Django Database Transactions
This post details how to make Celery work nicely with Django Database Transactions. -
Django in Production - II
Second part of the series covering how to get your django project into production -
Django in Production - II
Second part of the series covering django app deployment Now we’re done with the basic django deployment using gunicorn, now it’s time to make our server scalable. Let’s add a reverse proxy server NGINX and serve our site on port 80. NGINX Installation If you’re using Ubuntu, run the following commands: sudo apt-get update sudo apt-get install nginx Now you can check the status of nginx by running command: sudo systemctl status nginx NGINX Configuration So, for running NGINX you’ll need to write configuration files. They’re stored in the /etc/nginx/sites-available/ directory. Let’s first go into that directory by running: cd /etc/nginx/sites-available/ Now let’s create a file by doing: sudo touch django.conf And now let’s open the file in the editor by doing: sudo nano django.conf Hint: We need to use sudo here because this directory is present in root and not inside our home directory. Then paste the below config inside it. server { server_name server_domain_or_ip; location / { include proxy_params; proxy_pass http://localhost:8000; } } In place of server_domain_or_ip you’ll put either IP address or the domain of your website. So NGINX uses this concept where you can have multiple configuration files as backup stored under /etc/nginx/sites-available/. But the active … -
Django News - No DjangoCon US this year ☹ - Jun 19th 2020
News DjangoCon US 2020 is Canceled After 12 consecutive years of DjangoCons in the United States, we’ve decided to cancel DjangoCon US 2020. djangoproject.com Django 3.1 Beta 1 Released Django 3.1 beta 1 is now available. It represents the second stage in the 3.1 release cycle and is an opportunity for you to try out the changes coming in Django 3.1. djangoproject.com Wagtail Space US 2020 – Call For Proposals The Wagtail Space US CFP deadline is open until July 1, 2020. google.com 2020 Python Software Foundation Board of Directors Election Results The 2020 Python Software Foundation Board of Directors election has concluded. See the results! blogspot.com Articles Postgres websearch in Django 3.1 Django 3.1 includes a new Postgres SearchQuery feature that allows human-formatted search queries. jamesturk.net Optimizing Django ORM Queries If you love optimization articles where they present SQL queries next to Django ORM calls, then you are in for a treat. schegel.net Use Pathlib in Your Django Settings File Get a jump on Django 3.1 and switch to pathlib in your projects. adamj.eu How I manage multiple development environments in my Django workflow using Docker compose A practical Docker Compose overview for how to handle both development and … -
Working with Celery and Django Database Transactions
This post details how to make Celery work nicely with Django Database Transactions. -
Django in Production - I
-
Django in Production - I
Hello djangonauts, today I want to talk about how to run django in production. Introduction So, you might have finished developing that project you were building for your client, and now it’s time to deploy your project on a server and make it accessible to public. But you’re confused on how to proceed further? I was too, but not anymore. The reason why I decided to write this series is that when I had to deploy my project, I had to spend hours searching about it and then read up multiple articles about it, but even then they didn’t cover all the essential details. So that’s what prompted me to write this series, and I am going to go over my setup for running django in production. First thing, I wanna clear up is that when you run your django server using the command: python manage.py runserver This starts up a development server, that is provided by the Django Team only for the purpose of development, you are not supposed to run your projects in production using it. In production, you’ll have to use a WSGI server such as Gunicorn or uWSGI, which I’m going to cover as well. Deployment … -
Hackathon App - Building SaaS #61
In this episode, we took a break from the regular app to work on an app for a local hackathon that I’m participating in. My team is building a mobile web app for the homeless around Frederick, MD. In this stream, we cranked through some modeling, admin building, a couple of pages, tests, and templates! We got a lot done! The virtual hackathon running in Frederick is split into multiple teams serving three different community groups around Frederick county. -
Modern Django Development - Jeff Triplett
Jeff Triplett personal sitePython Software FoundationDjango Release Cycle REVSYSDjango News Newsletterawesome-djangoDEFNATailwind CSS -
Sending Confirmation Emails with Flask, Redis Queue, and Amazon SES
This blog post looks at how to send confirmation emails to newly registered users with Flask, Redis Queue, and Amazon SES. -
Django Best Practices: Custom User Model
Django ships with a built-in [User model](https://docs.djangoproject.com/en/4.0/ref/contrib/auth/#django.contrib.auth.models.User) for authentication and if you'd like a basic tutorial on how to implement log in, log out, sign up and so on see … -
How to Automatically Retrying Failed Celery Tasks
In this tutorial, we'll look at how to automatically retry failed Celery tasks.