Django Styleguide
👀 Need help with your Django project? HackSoft can make it easy for you. Reach out atconsulting@hacksoft.io
Table of contents:
Posted on April 2, 2020
We're reviewing our roadmap for the next 12 months and we'd love your input. If you use Wagtail, please help shape our plans.
The PSF’s priority is the health and safety of the community and the COVID-19 (Coronavirus) pandemic has made it unsafe to hold PyCon US this year.
A new Pipenv release is due at the end of the month.
From Adam Johnson, a demonstration of using check constraints in a Django model.
Notes on working remotely from a leading Django consultancy.
Notes from a PyCascades 2020 talk on using Django's built-in translation app.
How (and why) to use Django's ORM to generate a Postgres VIEW.
A look at the various ways to implement Django permissions.
How to implement double-checked locking within Django.
Creating a Django web interface for an existing Machine Learning platform.
From HackSoft, a styleguide for Django projects at scale.
👀 Need help with your Django project? HackSoft can make it easy for you. Reach out atconsulting@hacksoft.io
Table of contents:
Sage was a 2019 Google Summer of Code student and contributed cross-db JSONField support coming in Django 3.1. We discuss his background in programming and advice for future student contributors.
A discussion of Pipenv, virtualenv, and PyCon with Kojo Idrissa.
A look at Django's APPEND_SLASH setting which automatically adds a trailing slash to URL paths if the user doesn't add one themself.
A short guide to personalizing the Python interpreter prompt.
A robust comparison of Django's ORM to SQLAlchemy, typically used with Flask.
Alpine.js is a great JS framework to have in your toolbox when you don't need a big framework like Vue or React yet shares a similar syntax with Vue. The best part is that you can start using it by linking to a CDN version without having to configure or compile anything.
Go to the Alpine docs for most things: Alpine Docs
You are welcome to submit updates to the docs by submitting a PR to this repo. Docs are located in the /packages/docs
directory.
Stay here for contribution-related information.
Looking for V2 docs? here they are
npm install
& npm run build
/packages/alpinejs/dist/cdn.js
file from a <script>
tag on a webpage and you're good to go!You can get everything installed with: npm install
in the root directory of this repo after cloning it locally.
This repo is a "mono-repo" using npm workspaces for managing the packages. Each package has its own folder in the /packages
directory.
Rather than having to run separate builds for each package, all package bundles are handled with the same command: npm run build
Here's a brief look at each package in this…
Provides template tags, view decorators, and middleware to add and verify honeypot fields to forms.
Django application that provides utilities for preventing automated form spam.
Provides template tags, view decorators, and middleware to add and verify honeypot fields to forms.
Written by James Turk with contributions by Flavio Curella and Daniel Greenfeld.
Source: https://github.com/jamesturk/django-honeypot/
(django-honeypot 0.7 supports Django 1.11 and Python 2.7)
Be sure to add honeypot
to INSTALLED_APPS
in settings.py.
You will almost always need to define HONEYPOT_FIELD_NAME
which is the name to use for the honeypot field. Some sophisticated bots will attempt to avoid fields named honeypot, so it may be wise to name the field something slightly more realistic such as "phonenumber" or "body2".
HONEYPOT_VALUE
is an option that you can specify to populate the honeypot field, by default the honeypot field will be empty and any text entered into it will result in a failed POST. HONEYPOT_VALUE
can be a string…
Django management command to programmatically create usable super users.This is great for local Docker development, but please skip for production.
… provides a Django management command to create ready-to-login super users during development.
Install the pip package locally or globally:
pip install [--user] django-createsuperuserwithpassword
Enable the Django management command by extending your Django project settings:
INSTALLED_APPS += ("django_createsuperuserwithpassword", )
Call the command — e.g. from within a container entrypoint script — like this:
python manage.py createsuperuserwithpassword \
--username admin \
--password admin \
--email admin@example.org \
--preserve
If you want to help fix a bug, an easy way to spin up a development environment is:
git clone https://github.com/hartwork/django-createsuperuserwithpassword
cd django-createsuperuserwithpassword
docker-compose up --build
django-createsuperuserwithpassword is based on code by Adam Charnock licensed under the MIT license that started out at adamcharnock/swiftwind-heroku.
Sebastian Pipping added and fixed a few things, on top.
Posted on April 2, 2020
Sign up to receive the latest update from our blog.
September 25, 2020