Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
My 5 Favorite Talks at DjangoCon Europe 2019
This year DjangoCon Europe happened in Copenhagen, Denmark, at a very creative and special place AFUK - Academy for Untamed Creativity. Surrounded by artistic souls, we learned more about web technologies, got to know each other at ecologic reusable disposable cups of coffee, enjoyed delicious authentic food, and socialized with Django-branded beverages. As always, there was also a party with people drinking IPA (not to be confused with API). And at the weekend Django developers were solving bugs for Django and related open-source software at the coding sprints. Here I would like to present you with the top 5 talks that I liked most of all. Django and Web Security Headers Adam Johnson (@AdamChainz) was talking about special response headers that tell browsers to treat data of the website more securely and which Django settings are responsible for those headers. Summary by rixx Docs or it didn't Happen! Mikey Ariel (@ThatDocsLady) was talking about the necessity of documentation and what to write there. Summary by rixx Pushing the ORM to its Limits Sigurd Ljødal (@sigurdlj) was talking about advanced Django ORM use cases. Summary by rixx Logging Rethought 2: The Actions of Frank Taylor Jr. Markus Holtermann (@m_holtermann) was talking … -
Sending real-time push notifications with Django, Celery and Redis
Easily improve communication with your users by delivering timely and relevant information.What’s a push notification?It’s a medium for a mobile app to deliver certain information that requires the user’s attention. Unlike pull notifications, in which the client must request information from a server, push notifications originate from the server. These cover a wide variety of use cases ranging from a flight delay alert to a social network update or a newly released feature from the app, and the list goes on.iOS push notifications. Photo by Jamie Street on UnsplashWhy am I reading this?The objective of the following post is to get a bird’s eye view of what it’s like to implement a Django based solution, using Celery and Redis, to deliver real-time push notifications upon user interaction in a mobile app through Firebase Cloud Messaging(a.k.a. FCM) or Apple Push Notification Service(a.k.a. APNS). Don’t worry, it sounds harder than it looks.Heads upThis article assumes you already have a Django environment already set up and running. If that’s not the case, you’d be better off doing that first. There’s plenty documentation out there to start from scratch.It’s not within the scope of this post to explain the setup of FCM or APNS, … -
How to Design an Effective Landing Page
Landing pages are effective only if you know exactly what and to whom you wish to sell. And while an awesome landing page will not necessarily turn visitors into buyers, it will help you find buyers among visitors. The post How to Design an Effective Landing Page appeared first on Distillery. -
Getting a Django Application to 100% Coverage
Code coverage is a simple tool for checking which lines of your application code are run by your test suite. 100% coverage is a laudable goal, as it means every line is run at least once. Coverage.py is the Python tool for measuring code coverage. Ned Batchelder has maintained it for an incredible 14 years! I like adding Coverage.py to my Django projects, like fellow Django Software Foundation member Sasha Romijn. Let’s look at how we can integrate it with a Django project, and how to get that golden 100% (even if it means ignoring some lines). Configuring Coverage.py Install coverage with pip install coverage. It includes a C extension for speed-up, it’s worth checking that this installs properly - see the installation docs for information. Then set up a configuration file for your project. The default file name is .coveragerc, but since that’s a hidden file I prefer to use the option to store the configuration in setup.cfg. This INI file was originally used only by setuptools but now many tools have the option to read their configuration from it. For Coverage.py, we put our settings there in sections prefixed with coverage:. The Run Section This is where we … -
"Create Table As Select" in Django
A discussion recently came up on django-developers mailing list about how to build the SQL query CREATE TABLE ... AS SELECT (CTAS) with Django’s ORM. This statement and its cousin INSERT ... SELECT are useful for re-shaping data inside your database, using SELECT queries. They can be useful for building aggregate tables from complicated, slow queries, as a way of imitating materialized views on databases that don’t support them. Django doesn’t support these at current, but I found it’s not hard to implement using some Django ORM internals, and have an example function below. (Support might have changed by the time you’re reading this - check the linked mailing list thread!) Example Use Case For example, you might have a widget_summary table for analytics purposes built with a SELECT from your widget table joined with flimflams. You can then regularly rebuild the table with that CTAS query. We do this in a transaction on databases with transactional DDL (PostgreSQL, SQLite). Start a transaction, drop the table, recreate it with CTAS, and commit. On databases without transactional DDL, we need a temporary table. Create the table with a new name, hot-swap it in place with the atomic RENAME, then drop the … -
Improving Page Speed with Incremental Loading
Summary: you can use django-include-by-ajax to improve the performance and usability of your website by forcing some parts of the Django website page to be loaded and shown before other parts of the page. Web browsers load and render traditional HTML pages from top to down, from left to right and as a developer you have little control over what will be shown first, second, and last. However, sometimes you need a different loading sequence to improve user experience and usability. Let's examine a couple of cases when it is advantageous to have primary content showing up immediately and secondary content loading in a moment. Case 1. Above the Fold vs. Below the Fold People want speed. 47% of visitors expect the website to be loaded in less than 2 seconds. If the website takes more than 3 seconds to show up, it's a big chance, that you will lose 40% of visitors. If you sell something on your website, every one-second delay causes 7% fewer visitors becoming buyers. One technique to improve the perception of the speed of the website is to display the visible part of the screen as soon as possible, and then load the rest of … -
Improving Page Speed with Incremental Loading
Summary: you can use django-include-by-ajax to improve the performance and usability of your website by forcing some parts of the Django website page to be loaded and shown before other parts of the page. Web browsers load and render traditional HTML pages from top to down, from left to right and as a developer you have little control over what will be shown first, second, and last. However, sometimes you need a different loading sequence to improve user experience and usability. Let's examine a couple of cases when it is advantageous to have primary content showing up immediately and secondary content loading in a moment. Case 1. Above the Fold vs. Below the Fold People want speed. 47% of visitors expect the website to be loaded in less than 2 seconds. If the website takes more than 3 seconds to show up, it's a big chance, that you will lose 40% of visitors. If you sell something on your website, every one-second delay causes 7% fewer visitors becoming buyers. One technique to improve the perception of the speed of the website is to display the visible part of the screen as soon as possible, and then load the rest of … -
How to Switch to a Custom Django User Model Mid-Project
The Django documentation recommends always starting your project with a custom user model (even if it's identical to Django's to begin with), to make it easier to customize later if you need to. But what are you supposed to do if you didn't see this when starting a project, or if you inherited a project without a custom user model and you need to add one? At Caktus, when Django first added support for a custom user model, we were still using South for migrations. Hard to believe! Nearly six years ago, I wrote a post about migrating to a custom user model that is, of course, largely obsolete now that Django has built-in support for database migrations. As such, I thought it would be helpful to put together a new post for anyone who needs to add a custom user model to their existing project on Django 2.0+. Background As of the time of this post, ticket #25313 is open in the Django ticket tracker for adding further documentation about this issue. This ticket includes some high-level steps to follow when moving to a custom user model, and I recommend familiarizing yourself with this first. As noted in the … -
How to Switch to a Custom Django User Model Mid-Project
The Django documentation recommends always starting your project with a custom user model (even if it's identical to Django's to begin with), to make it easier to customize later if you need to. But what are you supposed to do if you didn't see this when starting a project, or if you inherited a project without a custom user model and you need to add one? -
How to: Run Django using Docker and Docker Compose
Read the full article -
Steaming on, eating jam
Image credit: The SmithsonianIn the last few months, development of the upcoming Evennia 0.9 has been steaming on. Evennia is, as you may know, a Python library for creating text-based multiplayer games (MUDs, MUSH etc).But it's not all backend work! There is also some sweet game-jamming going on, I get to that at the end. Evennia progress towards Python3 The regular Evennia develop branch is now running completely in Python 3. Since we are using some new features of this Python release, we will be aiming for Python 3.7 as a minimum version once Evennia 0.9 goes stable. We will also use Django 2.1 and likely Twisted 19 - so we'll be pretty much up-to-date on all our main dependencies.Now, while the release of Evennia 0.9 is still some time away (there are a bunch of regular bug fixes and minor features that I want to get in there too (see the progress here on the github 0.9 project page), it's worth to consider how much work it'll be for you to migrate and if you should wait or jump in right now.If you are new, I still recommend you use regular master branch Evennia (using Python 2.7). This is … -
Congrats to Distillery Partner PubNub on $23M in Series D Funding!
Following its $23M Series D round of funding, global data stream network (DSN) PubNub has the funding it needs to achieve its next stage of growth. The post Congrats to Distillery Partner PubNub on $23M in Series D Funding! appeared first on Distillery. -
My questions for prospective employers (Director/VP roles)
Last time I was looking for a job, I wrote up a list of questions I wanted to ask prospective employees. I just ran across the list again, and figured I’d share. I was looking for a senior management role (Director/VP-level) in Engineering or Security, so the questions are sloped in that direction. Also note that I was in a fairly strong position; I didn’t need the a job immanently. So, I was able to ask fairly direct, challenging questions. -
Family Trip to Joshua Tree
We took a family trip to Joshua Tree National Park to see the spring wildflowers in bloom. Our daughter Uma loved the fresh air and sunshine. Here, Daniel and Uma enjoy the beautiful scenery of the giant boulders. -
Family Trip to Joshua Tree
We took a family trip to Joshua Tree National Park to see the spring wildflowers in bloom. Our daughter Uma loved the fresh air and sunshine. Here, Daniel and Uma enjoy the beautiful scenery of the giant boulders. -
Family Trip to Joshua Tree
We took a family trip to Joshua Tree National Park to see the spring wildflowers in bloom. Our daughter Uma loved the fresh air and sunshine. Here, Daniel and Uma enjoy the beautiful scenery of the giant boulders. -
Avoid Memory Issues with Django’s bulk_create
When inserting a large number of objects into the database with Django, your first thought should be to use bulk_create. It is much more efficient than calling create for each object, and it generally only results in a single query. However, when dealing with tens of thousands, hundreds of thousands, or even more objects, you … Continue reading Avoid Memory Issues with Django’s bulk_create The post Avoid Memory Issues with Django’s bulk_create appeared first on concise coder. -
Avoid Memory Issues with Django’s bulk_create
When inserting a large number of objects into the database with Django, your first thought should be to use bulk_create. It is much more efficient than calling create for each object, and it generally only results in a single query. However, when dealing with tens of thousands, hundreds of thousands, or even more objects, you … Continue reading Avoid Memory Issues with Django’s bulk_create The post Avoid Memory Issues with Django’s bulk_create appeared first on concise coder. -
React Hooks - A deeper dive featuring useContext and useReducer
This article looks at how React JS hooks can be used to make React applications and their state management clean and efficient. -
Distillery Is Now a Certified Google Cloud Technology Partner!
We couldn’t be happier to announce that Distillery has now been certified as a Google Cloud Technology Partner! You might even say we’re on cloud nine about it. The post Distillery Is Now a Certified Google Cloud Technology Partner! appeared first on Distillery. -
Jupyter Notebook Server with AWS EC2 and AWS VPC
# Create your VPC You need a ... -
Summaries of the Python meetup in Amsterdam
I've made notes again at the 2019-04-11 Amsterdam Python meetup in the byte office. Here are the summaries. Ethics in IT - Nick Groenen Computer systems are taking over the world. They're influencing everything. A lot of good has come out of this. But there's also a downside. We're talking (at meetups like this, for instance) mostly about tech, not about the people that build it or the people affected by it. Nick Groenen calls that an ethics problem. As an example, Uber's "greyball" that was originally written for a good purpose but that was later used to mislead governments. Same with Volkswagen's diesel emissions scandal: detecting when there's an official test and adjusting the motor parameters to seem more environmentally friendly. How ethical is it to work on something like that? The above examples are of big companies. But what about working for smaller companies? You have the same ethical challenges there. What are you doing with your logfiles? How much information do you mine about your customers? Do you give customers' data to your boss when he asks about it even though it isn't allowed by your privacy policy? And how do you treat new programmers? Is there … -
How to Score A+ for Security Headers on Your Django Website
This is a blog post version of the talk I gave at DjangoCon Europe 2019 on the 10th April. The web is an evolving platform with a lot of backwards compatibility concerns. New web security practices often come from a realization that an old feature has some flaw. Rather than break old websites by changing such features, there are a bunch of more secure behaviours to opt in to. You can do this by setting HTTP headers. Securityheaders.com is a tool run by security consultant Scott Helme to create a report on these security headers. It gives any URL a score from F to A+, which is a nice simple way of measuring your security posture. Though, like any automated report, it needs need some human interpretation to factor in context. (I’d also recommend the Mozilla Observatory security scanner, but I’m not using it here because it does way more than security headers.) As an example, Yahoo scores an A+ on Securityheaders.com: Whilst (at time of writing) Google scores a C: This is a guide on how to configure a typical Django web application to score that magic A+. You can beat Google, protect your users, and impress your boss, … -
5 Things to Keep in Mind When Designing Your Business Logo
When designing your logo, you should pay close attention from the very first step in the design process. After all, your logo says a lot about your business. The post 5 Things to Keep in Mind When Designing Your Business Logo appeared first on Distillery. -
How to Save Extra Data to a Django REST Framework Serializer
In this tutorial you are going to learn how to pass extra data to your serializer, before saving it to the database. Introduction Example Using APIView Example Using ViewSet Introduction When using regular Django forms, there is this common pattern where we save the form with commit=False and then pass some extra data to the instance before saving it to the database, like this: form = InvoiceForm(request.POST) if form.is_valid(): invoice = form.save(commit=False) invoice.user = request.user invoice.save() This is very useful because we can save the required information using only one database query and it also make it possible to handle not nullable columns that was not defined in the form. To simulate this pattern using a Django REST Framework serializer you can do something like this: serializer = InvoiceSerializer(data=request.data) if serializer.is_valid(): serializer.save(user=request.user) You can also pass several parameters at once: serializer = InvoiceSerializer(data=request.data) if serializer.is_valid(): serializer.save(user=request.user, date=timezone.now(), status='sent') Example Using APIView In this example I created an app named core. models.py from django.contrib.auth.models import User from django.db import models class Invoice(models.Model): SENT = 1 PAID = 2 VOID = 3 STATUS_CHOICES = ( (SENT, 'sent'), (PAID, 'paid'), (VOID, 'void'), ) user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='invoices') number = models.CharField(max_length=30) date = …