DEV Community

Jeff Triplett (he/him) for Django News

Posted on • Originally published at django-news.com on

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

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).

View live demo

<article class="prose lg:prose-xl">
  {{ markdown }}
</article>

Installation

Install the plugin from npm:

# Using npm
npm install @tailwindcss/typography
# Using Yarn
yarn add @tailwindcss/typography

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@tailwindcss/typography'),
    // ...
  ],
}

Using a CDN

If you need to pull in these styles via CDN, you can do so using services like UNPKG or jsDeliver:

<!-- From UNPKG -->
<link
  rel="stylesheet"
  href="https://unpkg.com/@tailwindcss/typography@0.2.x/dist/typography.min.css"
/&gt
<!-- From jsDelivr -->
<link
  rel="

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

Docker version info

$ docker version

Show info like number of containers, etc

$ docker info

WORKING WITH CONTAINERS

Create an run a container in foreground

$ docker container run -it -p 80:80 nginx

Create an run a container in background

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

Shorthand

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

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

rtd pypi-v pypi-pyversions pypi-l pypi-wheel circleci codecov

What is websockets?

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

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
import websockets
async def hello(uri):
    async with websockets.connect(uri) as websocket:
        await websocket.send("Hello world!")
        await websocket.recv()

asyncio.get_event_loop().run_until_complete(
    hello('ws://localhost:8765'))

And here's an echo server:

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

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

asyncio.get_event_loop().run_until_complete(
    websockets.serve(echo, 'localhost', 8765))
asyncio

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 file.

Goodconf

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] if parsing/generating YAML 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, Value

class Config(GoodConf):
    "Configuration for My App"
    DEBUG = Value(default=False, help="Toggle debugging.")
    DATABASE_URL = Value(
        default='postgres://localhost:5432/mydb',
        help="Database connection.")
    SECRET_KEY = Value(
        initial=lambda: base64.b64encode(os.urandom(60)).decode(),
        help="Used for cryptographic signing. "
        "https://docs.djangoproject.com/en/2.0/ref/settings/#secret-key")

config = Config(
    default_files=["/etc/myproject/myproject.yaml", "myproject.yaml"]
)

Next, use the config…

Discussion (0)