swapify - Swappables in South
After the custom user model was brought upon the Django community, it had all the attention it well deserved and more and more re-usable apps are providing support for custom user models.
I’ve been working with django-oscar and many of its extensions over the past two years. Oscar added support for the custom user models in its 0.6 release and django-fancypages even goes beyond that and leverages the (hidden) swappable API.
One of the few things that could be considered troublesome with models that are swappable, is providing compatible South migrations. Over the last few months, I’ve had to touch enough migrations and replace auth.User with AUTH_USER_MODEL to be annoyed by it and automate the situation.
Behold swapify, the little commandline tool that fixes your migrations for a swappable model of your choice (on at a time). It checks your migration files for you swappable and updates the migrations if required.
This is a first attempt based on my own experiences. There’s probably uncovered ground and potential for improvement out there…so feedback is very welcome.
Enjoy!
Installation
You can either install the latest release from PyPI:
pip install swapify
or install the latest development version from github:
pip install https://github.com/elbaschid/swapify/archive/master.tar.gz
Usage
Get a list of all migrations in a directory that require fixing:
swapify list myproject/ --model auth.User
Update all migrations to work with swapped models:
swapify apply myproject/ --model auth.User
You can also test updating the files and get the output on stdout:
swapify apply myproject/ --model auth.User --dry-run
And for very custom models you can even do:
swapify apply myproject/ --model swap.Swappable --var-name MYSWAP_SWAPPABLE_MODEL
License
swapify is available under the MIT license.
Metadata
Release files for swapify 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swapify-0.1.1.tar.gz | 8.9 kB | Without provenance | Details for swapify-0.1.1.tar.gz |
Release files / swapify-0.1.1.tar.gz
| Download URL | swapify-0.1.1.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adf962677050ff8c0866ffc9cf810977cc1b782f397f4d283ecd2d12a58cae76
|
|
BLAKE2b-256 checksum How to use checksums |
d01a1ac4877fd17e0126018e5812acc933ae2cba5b8454e3d4af9fac2f05de46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for swapify 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.