Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Fixing Up Permissions After Data Migration in Django
Find out how I fixed my permissions after I imported my data -
The best frontend JavaScript framework for Django
A question I've seen asked a lot is "what's the best frontend JavaScript framework to use with Django". Django itself doesn't make any recommendation on which frontend framework to use, or even assumes you're using a frontend framework at all. So, which frontend framework should you be using? And which one "plays well" with Django? Defining "the best" The problem with such questions is that "the best" is often ill-defined. Best based on what criteria? If you're starting a new project and wondering which one to choose, the disappointing answer I have for you is this: The best frontend JavaScript framework is one you already know well That's it. If you, or your team, wants to use a frontend framework, the best one to use is the one that you and your team have the most familiarity with. That's because it's very likely that you will be more productive with it. Django "plays well" with any frontend JavaScript framework, by virtue of the fact that it makes no assumptions and does not force you to use any framework. In that respect, it's all the same. At the end it's all JavaScript. The actual question But of course, that's not what … -
Django tarpit for malicious requests
While checking my logs for this site and seeing the usual malicious requests against every spammers favorite software WordPress I decided to make things a little harder for them with a [tarpit](https://en.wikipedia.org/wiki/Tarpit_(networking)). -
Thoughts on „Surviving Django“
Daniele, the author of psycopg2, wrote an interesting post about Django and its migration system. Having used Django for well over a decade and having worked on projects either handed to me or greenfield at different scales I cannot agree with his arguments as they are stated. The migration and ORM system does solve a far larger problem than allowing web apps to switch between databases. Djangos migration system is primarily a developer tool. A rather excellent one I cannot praise enough. It abstracts and standardises the way database migrations are handled. Remember following a document outlining the order of 15 migrations to apply when doing a deploy? Remember trying to add a 16th? I surely prefer running makemigrations. Is it perfect? No. Can a talented DBA get far more out of a database? Absolutely. Is any of that more relevant than safeguards and ease of use for 90% of the apps out there? Definitely not. Now to the really good part – you can have the best of both worlds! Migrations can run Python and SQL, while still giving you some of the safeguards and making it comfortable to use. They will not get in your way, but spare … -
Thoughts on „Surviving Django“
Daniele, the author of psycopg2, wrote an interesting post about Django and its migration system. Having used Django for well over a decade and having worked on projects either handed to me or greenfield at different scales I cannot agree with his arguments as they are stated. The migration and ORM system does solve a far larger problem than allowing web apps to switch between databases. Djangos migration system is primarily a developer tool. A rather excellent one I cannot praise enough. It abstracts and standardises the way database migrations are handled. Remember following a document outlining the order of 15 migrations to apply when doing a deploy? Remember trying to add a 16th? I surely prefer running makemigrations. Is it perfect? No. Can a talented DBA get far more out of a database? Absolutely. Is any of that more relevant than safeguards and ease of use for 90% of the apps out there? Definitely not. Now to the really good part - you can have the best of both worlds! Migrations can run Python and SQL, while still giving you some of the safeguards and making it comfortable to use. They will not get in your way, but spare … -
Django News - Django 3.1 Release - Aug 7th 2020
News Django 3.1 Released 3.1 is live! You can read the release notes. Please take a moment to thank our two Django Fellows, @MariuszFelisiak and @carltongibson, who made this release possible. djangoproject.com Django REST Framework 3.11.1 Released github.com Upgrade to pip 20.2, plus, changes coming in 20.3 The newest version of pip, 20.2, is now released. You can install it by running python -m pip install --upgrade pip. blogspot.com Django bugfix releases issued: 3.0.9 and 2.2.15 djangoproject.com Python Developers Survey 2019 Results The results of JetBrains' annual survey is out. jetbrains.com Articles Django 3.1 Async Django 3.1 introduces asynchronous views, middlewares, and tests. This article walks you through those features. wersdoerfer.de A breakdown of how NGINX is configured with Django Matt Segal covers Nginx in depth. mattsegal.dev Backporting a Django ORM Feature with Database Instrumentation How to use database instrumentation to backport a Django ORM feature. adamj.eu Some SQL Tricks of an Application DBA Haki Benita's guide to non-trivial tips for database development. hakibenita.com Goodconf: A Python Configuration Library Lincoln Loop recently released Goodconf and this is their guide to why and how to use it. lincolnloop.com Why you shouldn’t remove your package from PyPI Gonçalo Valério covers how to … -
How to make Django request.is_ajax() work with JS fetch()
Django's request object has a nifty little method is_ajax. It allows determining whether a request comes from a JS framework (aka old-school ajax). While it works fine with some JS libraries, including the venerable jQuery, it won't work with modern JS native fetch API out of the box. … Read now -
Introducing Django ClearCache 🤠🧹💰 - allows to clear cache via admin UI or command line
I've been working with the Django cache recently. And while Django has exceptional caching capabilities, I was surprised to find out that it doesn't provide a simple way to manually clear a cache. I checked online and found a couple of clear cache packages for Django, but all of them … Read now -
Brief reflections on programming languages I have worked with during my career
I've played and worked with multiple programming languages over my 15-year long career in development (and a bit before, when I studied at school and university). Every language I touched left a piece of knowledge or a feeling in me. So I decided to remember them all and try to … Read now -
The Simplest Way to Create a Python Virtual Environment
A lot of fog and mysteries surround Python virtual environments. There are loads of packages, tools, and wrappers trying to make developer's life with virtual environments easier. But if we look at the basics, we'll see that actually, creating a virtual environment in Python has never been easier. Starting from … Read now -
How to sort Django admin list column by a value from a related model
Here's the real-life case. On this blog, I have two models: Post and PostStats. The former is, as you might have guessed, for posts, while the latter is for per post statistics like a view count. Here's a simplified version of both models: class Post(models.Model … Read now -
Non-Django issues during a Django upgrade
Upgrading from Django 3.0.9 to 3.1 was a breeze. To be fair upgrading Django is usually a breeze. The exhausive release notes written every time a new version is rolled out is a defining factor here. What do I mean when I say “a breeze”? I compare Django “upgrades” to something like upgrading a Python 2 codebase to Python 3 😬 So, upgrades being a breeze, why write a post about this topic? Because a Django application usually does not comprise only of the Django package. How I upgraded This section basically is about “how I usually upgrade”. Made specific for this 3.0.9 to 3.1 upgrade. Steps Changed Django version in requirements.txt file. I.e. changed entry from Django==3.0.9 to Django==3.1. Ran pip install -r requirements.txt with the updated requirements file. Among the command’s output I spotted: Installing collected packages: Django Found existing installation: Django 3.0.9 Uninstalling Django-3.0.9: Successfully uninstalled Django-3.0.9 Successfully installed Django-3.1 Ran ./manage.py check This yielded several warnings of the type: $ ./manage.py check System check identified some issues: WARNINGS: app_name.Model.field_name: (fields.W904) django.contrib.postgres.fields.JSONField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0. HINT: Use django.db.models.JSONField instead. ... System check identified 3 issues … -
Thoughts on „Surviving Django“
Thoughts on „Surviving Django“ Daniele, the author of psycopg2, wrote an interesting post about Django and its migration system. Having used Django for well over a decade and having worked on projects either handed to me or greenfield at different scales I cannot agree with his arguments as they are stated. The migration and ORM system does solve a far larger problem than allowing web apps to switch between databases. Djangos migration system is primarily a developer tool. A rather excellent one I cannot praise enough. It abstracts and standardises the way database migrations are handled. Remember following a document outlining the order of 15 migrations to apply when doing a deploy? Remember trying to add a 16th? I surely prefer running makemigrations. Is it perfect? No. Can a talented DBA get far more out of a database? Absolutely. Is any of that more relevant than safeguards and ease of use for 90% of the apps out there? Definitely not. Now to the really good part - you can have the best of both worlds! Migrations can run Python and SQL, while still giving you some of the safeguards and making it comfortable to use. They will not get in … -
Give Me A Break... Day - Building SaaS #67
In this episode, we did some Django model development. I created a new model to track break days in a school year. This model will be critical to fill in vacations and holidays so that the scheduling functionality works properly. I added the model, the tests, the admin page, and the create view to create break days in the app. We started by picking a model name and discussing naming in programming. -
Multiple Image Files Upload with Django 3, Angular 10 and FormData
In the previous tutorial we have seen how to implement image file uploading in Django 3 and Angular 10. In this tutorial, we'll see how to implement multiple file uploading with FormData and HttpClient. Note: It's recommended that you start from the previous tutorial to see detailed steps of how to create a django 3 project, how to install Angular 10 CLI and generate a new Angular 10 project along with services and components as we won't cover these things in this tutorial. Working with Angular 10, Django 3 and FormData In this tutorial, we'll see how to use HTML5 FormData with Angular and django 3 to upload multiple image files from an Angular 10 frontend to a Python server. Let's get started by cloning a django 3 project with the single file uploading that was already implemented. Cloning the Angular 10 Upload Frontend If you don't want to follow the steps from the previous part, you first need to get the project we've built. Open a new terminal and run the following command: $ git clone https://github.com/techiediaries/django-angular-file-upload-example.git Next, navigate inside the project's folder and install the npm dependencies using the following command: $ cd django-angular-file-upload-example $ npm install Next, … -
WARNINGS (URLs.W005) URL namespace ‘admin’ isn’t unique. You may not be able to reverse all URLs in this namespace
Lets jump into this minor issue you face while running Django migrations. The issue also has a quick fix. The issue is encountered when we type the following command in your terminal: -
Django Password Reset Tutorial
In this tutorial we'll add a password reset sequence to our Django application. This builds upon our previous work where we added [Login & Logout](https://learndjango.com/tutorials/django-login-and-logout-tutorial) pages and then a [Signup … -
How I got a residency appointment thanks to Python, Selenium and Telegram
Hello everyone As some of you might know, I’m a Venezuelan 🇻🇪 living in Montevideo, Uruguay 🇺🇾. I’ve been living here for almost a year, but because of the pandemic my residency appointments have slowed down to a crawl, and in the middle of the quarantine they added a new appointment system. Before, there were no appointments, you just had to get there early and wait for the secretary to review your files and assign someone to attend you. But now, they had implemented an appointment system that you could do from the comfort of your own home/office. There was just one issue: there were never appointments available. That was a little stressful. I was developing a small tick by checking the site multiple times a day, with no luck. But then, I decided I wanted to do a bot that checks the site for me, that way I could just forget about it and let the computers do it for me. Tech Selenium I had some experience with Selenium in the past because I had to run automated tests on an Android application, but I had never used it for the web. I knew it supported Firefox and had … -
How I got a residency appointment thanks to Python, Selenium and Telegram
Hello everyone As some of you might know, I’m a Venezuelan 🇻🇪 living in Montevideo, Uruguay 🇺🇾. I’ve been living here for almost a year, but because of the pandemic my residency appointments have slowed down to a crawl, and in the middle of the quarantine they added a new appointment system. Before, there were no appointments, you just had to get there early and wait for the secretary to review your files and assign someone to attend you. But now, they had implemented an appointment system that you could do from the comfort of your own home/office. There was just one issue: there were never appointments available. That was a little stressful. I was developing a small tick by checking the site multiple times a day, with no luck. But then, I decided I wanted to do a bot that checks the site for me, that way I could just forget about it and let the computers do it for me. Tech Selenium I had some experience with Selenium in the past because I had to run automated tests on an Android application, but I had never used it for the web. I knew it supported Firefox and had … -
A minimal Websockets setup with Django in production
That's me wiring up my cool JS grid to autoload data changes via server side push. Yeah! Image credit: thedisgruntledsherpaproject.com Use Case I have a Handsontable implementation for an underlying database table. I.e. a “JavaScript data grid that looks and feels like a spreadsheet”. A requirement came up. Obvious in hindsight. Changes made to cells in one sheet should be reflected in the same sheet for other users. When the sheet is open in other browser tabs/windows. This calls for “server side push” using web sockets. I.e. the server needs to push a notification to open “clients”. Another way to do this would be to have client browsers Ajax-polling for changes. But that would be wasteful. Let’s only update the sheet when valid changes are saved! What does minimal mean in this case? This application is used by a team internally. Usage not exceeding ten concurrent users. The implications of this: One process to serve web socket requests is enough. No real performance testing was done. No consideration of alternatives to daphne such as uvicorn or starlette. I picked up daphne because it came up “first on the list of alternatives”. That’s it! No need to handle websocket interactions asynchronously … -
Set Default Date For Date Hierarchy In Django Admin
Introduction When we monitor daily events from django admin, most of the time we are interested in events related to today. Django admin provides date based drill down navigation page via ModelAdmin.date_hierarchy1 option. With this, we can navigate to any date to filter out events related to that date. One problem with this drill down navigation is, we have to navigate to todays date every time we open a model in admin. Since we are interested in todays events most of the time, setting todays date as default filtered date will solve the problem. Set Default Date For Date Hierarchy Let us create an admin page to show all the users who logged in today. Since User model is already registered in admin by default, let us create a proxy model to register it again. from django.contrib.auth.models import User class DjangoUser(User): class Meta: proxy = True Lets register this model in admin to show logged in users details along with date hierarchy. from django.contrib import admin @admin.register(DjangoUser) class MetaUserAdmin(admin.ModelAdmin): list_display = ('username', 'is_active', 'last_login') date_hierarchy = 'last_login' If we open DjangoUser model in admin page, it will show drill down navigation bar like this. Now, if we drill down to … -
Set Default Date For Date Hierarchy In Django Admin
Introduction When we monitor daily events from django admin, most of the time we are interested in events related to today. Django admin provides date based drill down navigation page via ModelAdmin.date_hierarchy1 option. With this, we can navigate to any date to filter out events related to that date. One problem with this drill down navigation is, we have to navigate to todays date every time we open a model in admin. Since we are interested in todays events most of the time, setting todays date as default filtered date will solve the problem. Set Default Date For Date Hierarchy Let us create an admin page to show all the users who logged in today. Since User model is already registered in admin by default, let us create a proxy model to register it again. from django.contrib.auth.models import User class DjangoUser(User): class Meta: proxy = True Lets register this model in admin to show logged in users details along with date hierarchy. from django.contrib import admin @admin.register(DjangoUser) class MetaUserAdmin(admin.ModelAdmin): list_display = ('username', 'is_active', 'last_login') date_hierarchy = 'last_login' If we open DjangoUser model in admin page, it will show drill down navigation bar like this. Now, if we drill down to … -
Django News - Django Developers Survey 2020 - Jul 31st 2020
News Django Developers Community Survey 2020 Please take a few minutes to complete the 2020 survey and help guide the future development of Django. djangoproject.com Abigail Dogbe Awarded the PSF Community Service Award for Q1 2020 From Django Girls workshop mentee in 2017 to lead organizer of PyLadies Ghana and co-organizer of PyCon Africa 2019, Abigail received the PSF Community Service Award for Q1 2020. blogspot.com Articles How to Use Django's Parallel Testing on macOS With Python 3.8+ by Adam Johnson Speed up parallel testing via this excerpt from Adam Johnson's book Speed Up Your Django Tests. adamj.eu Is Django too slow? A look at benchmarks and concurrency in Django vs competing web frameworks. mattsegal.dev Docker & Django local development: a minimal, step-by-step guide A beginner-friendly guide to Docker and Django local development. untangled.dev A Deep Dive into PostGIS Nearest Neighbor Search PostGIS adds geographic object support to PostgreSQL and is used in the GeoDjango module. crunchydata.com XSS Exploitation in Django Applications An overview of various exploits that can work against the Django templating engine in a modern web application. github.io Writing Models in Django A nice beginner's intro to creating a model and a superuser. hashnode.dev Tutorials How to … -
Docs, Bugs, and Reports - Building SaaS #66
In this episode, I created documentation for anyone interested in trying out the application. After documenting the setup, I moved on to fixing a bug with the scheduling display of courses. In the latter half of the stream, we focused on creating a new reports section to show progress reports for students. One of my patrons requested some documentation to explain how to get started with the project. We updated the README. -
Pros and Cons of Django Web Framework
Python is the 3rd most popular programming language in 2020. It is a powerful, dynamic, syntax-simplified, programming language used for high-level web application development and machine learning apps. And if you know about Python, you’ve probably heard of Django web framework – the most used Python framework. Django development has gained much fame due to its computation […] The post Pros and Cons of Django Web Framework appeared first on BoTree Technologies.