I've added Composite Keys to Django as a virtual field. That makes it works with timescale db
The story about how I worked on a library of 1000 lines of code for 10 years.
In this article, I’m going to share my development experience with the Django-FSM project. I will describe the process of building pythonic API, discovered pitfalls, and implemented a generic Finite State Machine library.
I have never been connected to any other project for so long. When I started developing Django-FSM, I couldn’t even expect that such a small piece of code could be developed and rewritten from scratch several times over the years. …
This article introduces a new concept in the upcoming Viewflow 2.0 library, Class-based URL configuration — Viewset. Viewsets allow developers to create reusable Django packages, simplifies configuration and redefinition behavior of a bunch of views with common functionality for an end user. In this article. we will go through Viewset functionality, usage patterns and compare them with other class-based implementations, like django.contrib.admin
and django-rest-framework
.
Django is a web-framework famous for its “batteries included” philosophy. There is a lot of built-in functionality in the library and the broad set of third-party packages solves any imaginable problem you could have. …
2020 is almost over, and it’s a good time to analyze what the most demanded Django packages in 2020 were.
There are pretty detailed PyPI package repository download statistics available at google cloud. Let’s explore the result of a simple query that collects the total number of downloads for any package with a name containingdjango
.
SELECT file.project, COUNT(*) as total_downloads
FROM `the-psf.pypi.file_downloads`
WHERE DATE(timestamp)
BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 360 DAY)
AND CURRENT_DATE()
AND file.project like '%django%'
GROUP BY file.project
ORDER BY total_downloads DESC
LIMIT 100
Download count outperforms some packages that have been in use in the most active projects and…
I have discovered a truly remarkable solution for composite foreign keys support in Django ORM that works well when you can’t modify an existing database.
A composite foreign key is a foreign key that consists of two or more columns. Request to support for multiple-column primary keys has been open for over 15 years in the Django Tracker. There have been several attempts to implement this functionality. Nevertheless, the best thing you can do is modify an existing database table. You have to drop the old composite primary key and replace it with a new auto-increment primary key.
Database modification…
Fresh Django project deployment always looks a bit cumbersome. Bunch of script files, configurations, and container infrastructure setup time could take more time than an actual MVP project. This article describes a way to deploy to a generic Ubuntu host, just with a single tool — Ansible, and the one-file deployment script.
The deployment could be really handy to get into production just after startproject/startapp commands, and before hiring a first member of your DevOps team.
If you already use Pipenv and Django-Environ just grab deploy.yml
put it into your project and go down to “Let’s deploy” section
Here is…
In the previous two parts, we created a simple backend and frontend with user authentication.
In this final part, we would perform our first authenticated call to the API and implement JWT Refresh Token workflow.
Let’s create a simple helper, that would add Authentication
header with token from our state.
reducers/index.js
...
export function withAuth(headers={}) {
return (state) => ({
...headers,
'Authorization': `Bearer ${accessToken(state)}`
})
}
Now we can create our first API action, in a new file actions/echo.js
import { RSAA } from 'redux-api-middleware';
import { withAuth } from '../reducers'export const ECHO_REQUEST = '@@echo/ECHO_REQUEST'; export const ECHO_SUCCESS =…
In the previous part, we created a simple django back-end with JSON Web token authentication. Now we going to make a frontend with React and Redux
To work over first part of the tutorial, you need to have nodejs, npm, and create-react-app installed.
Redux is a library helps to organize predictable, one-way data flow in a front-end application. Everything starts from a single source of truth — a store. A store could be modified only by firing actions. Actions go through Redux middleware down to the reducer functions. Reducer functions produce a new state. …
This article shows how to quick-start with SPA applications development using Django and React/Redux.
It’s hard to imagine a Django application without user authentication and authorization. So we start with a simple application that can authenticate a user and perform an authorized request to an API.
In addition, you will see how to setup redux-router, local state persistence with redux-persist and write a simple UI with reactstrap (bootstrap 4 binding for the React)
In the first part of the tutorial we will create a simple Django backend with JWT token authentication. …
I’m glad to announce 1.0 release of django-viewflow and django-material libraries, that took about 3 years of my part-time work.
Viewflow is the reusable workflow library for Django, that helps to implement people collaboration software. Viewflow takes best parts from two worlds. It is based on BPMN — business process modeling and notation standard. And plays well with modern web development toolchain.
We had such movement for sysadmin tools, that have become DevOps scripts, there are tons of ETL software that adopt the code-first approach to construct pipelines, instead of UI. Non-interactive computational job workflows use code to construct…