Issue 35 - Django 3.1 Release

jefftriplett

Jeff Triplett (he/him)

Posted on August 7, 2020

Issue 35 - Django 3.1 Release

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.


Django REST Framework 3.11.1 Released


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.


Django bugfix releases issued: 3.0.9 and 2.2.15


Python Developers Survey 2019 Results

The results of JetBrains' annual survey is out.


Articles

Django 3.1 Async

Django 3.1 introduces asynchronous views, middlewares, and tests. This article walks you through those features.


A breakdown of how NGINX is configured with Django

Matt Segal covers Nginx in depth.


Backporting a Django ORM Feature with Database Instrumentation

How to use database instrumentation to backport a Django ORM feature.


Some SQL Tricks of an Application DBA

Haki Benita's guide to non-trivial tips for database development.


Goodconf: A Python Configuration Library

Lincoln Loop recently released Goodconf and this is their guide to why and how to use it.


Why you shouldn’t remove your package from PyPI

Gonçalo Valério covers how to migrate your Python package to a new name and how to deprecate the old version.


A Story of How I Built This Website in Wagtail

Ria Parish walks us through a case study of building a blog with Django and Wagtail.


A minimal Websockets setup with Django in production

J.V. Zammit shows us how to setup WebSockets in production and an interesting use-case for doing so.


Tutorials

Official Django REST Framework Tutorial - A Beginners Guide

Will Vincent's beginner-friendly guide to Django Rest Framework.


Customize the Django Admin With Python

This Django Admin tutorial covers a little bit of everything.


Sponsored Link

Django Best Practices the Two Scoops Way - August 14 2020, 9:00 AM - 4:00 PM [PST]

A live online event where Daniel Feldroy, co-author of Two Scoops of Django, dives into Django and Python best practices. Attendees can ask questions and are encouraged to do so.


Projects

tailwindlabs/tailwindcss-typography

If you are loving TailwindCSS then check out their new plugin which you can use to add beautiful typographic defaults to any vanilla HTML you don't control (like HTML rendered from Markdown, or pulled from a CMS).

Tailwind CSS Typography Tailwind CSS Typography

A plugin that provides a set of prose classes you can use to add beautiful typographic defaults to any vanilla HTML you don't control, like HTML rendered from Markdown, or pulled from a CMS.


Documentation

For full documentation, visit tailwindcss.com/docs/typography-plugin.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss the Tailwind CSS Typography plugin on GitHub

For casual chit-chat with others using the framework:

Join the Tailwind CSS Discord Server







lifeeric/docker-cheat-sheet

If you have ever wanted a useful Docker cheatsheet, then this is that cheatsheet.

GitHub logo lifeeric / docker-cheat-sheet

All about docker commands

docker-cheat-sheet

Docker Commands, Help & Tips

Show commands & management commands

$ docker
Enter fullscreen mode Exit fullscreen mode

Docker version info

$ docker version
Enter fullscreen mode Exit fullscreen mode

Show info like number of containers, etc

$ docker info
Enter fullscreen mode Exit fullscreen mode

WORKING WITH CONTAINERS

Create an run a container in foreground

$ docker container run -it -p 80:80 nginx
Enter fullscreen mode Exit fullscreen mode

Create an run a container in background

$ docker container run -d -p 80:80 nginx
Enter fullscreen mode Exit fullscreen mode

Shorthand

$ docker container run -d -p 80:80 nginx
Enter fullscreen mode Exit fullscreen mode

Naming Containers

$ docker container run -d -p 80:80 --name nginx-server nginx

TIP: WHAT RUN DID

  • Looked for image called nginx in image cache
  • If not found in cache, it looks to the default image repo on Dockerhub
  • Pulled it down (latest version), stored in the image cache
  • Started it in a new container
  • We specified to take port 80- on the host and forward to port 80 on the container
  • We could do "$ docker container run --publish…

aaugustin/websockets

Library for building WebSocket servers and clients in Python.

GitHub logo aaugustin / websockets

Library for building WebSocket servers and clients in Python

websockets

licence version pyversions tests docs openssf

What is websockets?

websockets is a library for building WebSocket servers and clients in Python with a focus on correctness, simplicity, robustness, and performance.

Built on top of asyncio, Python's standard asynchronous I/O framework, it provides an elegant coroutine-based API.

Documentation is available on Read the Docs.

Here's how a client sends and receives messages:

#!/usr/bin/env python

import asyncio
from websockets import connect

async def hello(uri):
    async with connect(uri) as websocket:
        await websocket.send("Hello world!")
        await websocket.recv()

asyncio.run(hello("ws://localhost:8765"))
Enter fullscreen mode Exit fullscreen mode

And here's an echo server:

#!/usr/bin/env python
import asyncio
from websockets import serve

async def echo(websocket):
    async for message in websocket:
        await websocket.send(message)

async def main():
    async with serve(echo, "localhost", 8765):
        await asyncio.
Enter fullscreen mode Exit fullscreen mode

candylabshq/wagtail-opengraph-image-generator

Wagtail Open Graph Image Generator will assist you in automatically creating Open Graph images for your pages.

GitHub logo candylabshq / wagtail-opengraph-image-generator

Wagtail Open Graph Image Generator will assist you in automatically creating Open Graph images for your pages.

wagtail-opengraph-image-generator

Wagtail Open Graph Image Generator will assist you in automatically creating Open Graph images for your pages.

There are a handful of configuration options to popuplate images with your page's content Besides the title, there are options to provide a static company logo, subtitle, background image and page logo in the SVG format. While the resulting image will be a little bit opinionated, the defaults should work just fine in most cases.

The final image will be saved in the PNG format in a configurable Wagtail collection. It then can be used in your templates and code.

Features

  • Automatic creation of Open Graph protocol compatible images
  • Live preview and configuration in a seperate tab in the Edit and Create views
  • Several dynamic fields that can be configured to supply content for your generated image

Requirements

  • Python 3.6+
  • Wagtail 2.7 LTS or Wagtail 2.8
  • Django 2.2 LTS or Django 3.0

lincolnloop/goodconf

Transparently load variables from environment or JSON/YAML file.

GitHub logo lincolnloop / goodconf

Transparently load variables from environment or JSON/YAML/TOML file.

Goodconf

https://github.com/lincolnloop/goodconf/actions/workflows/test.yml/badge.svg?branch=main&event=push pre-commit.ci status

A thin wrapper over Pydantic's settings management Allows you to define configuration variables and load them from environment or JSON/YAML file. Also generates initial configuration files and documentation for your defined configuration.

Installation

pip install goodconf or pip install goodconf[yaml] / pip install goodconf[toml] if parsing/generating YAML/TOML files is required.

Quick Start

Let's use configurable Django settings as an example.

First, create a conf.py file in your project's directory, next to settings.py:

import base64
import os
from goodconf import GoodConf, Field
from pydantic import PostgresDsn

class AppConfig(GoodConf):
    "Configuration for My App"
    DEBUG: bool
    DATABASE_URL: PostgresDsn = "postgres://localhost:5432/mydb"
    SECRET_KEY: str = Field(
        initial=lambda: base64.b64encode(os.urandom(60)).decode(),
        description="Used for cryptographic signing. "
        "https://docs.djangoproject.com/en/2.0/ref/settings/#secret-key")

    class Config:
        default_files = ["/etc/myproject/myproject.yaml", "myproject.yaml"]

config = AppConfig
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
jefftriplett
Jeff Triplett (he/him)

Posted on August 7, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related