Generic reusable bits for Django projects
Project description
djinntoux
Generic reusable bits for Django projects
Disclaimer
This package is only intended for my own personal use, install at your own risk
Rebuild
Assumes twine is installed and an API token is stored in a .pypirc file:
rm -rfv dist/ && python -m build && twine upload --verbose dist/*
Installation
pip install djinntoux
Usage
dproj
settings_reuse
In your own project settings, use like so:
from djinntoux.dproj.settings_reuse import * # noqa
...
INSTALLED_APPS = BASE_APPS + []
This reusable settings module expects DJANGO_SECRET_KEY to be set in your environment. For example, if you are just running your project locally, you could use an .envrc file for your development environment ...
...
export 'DJANGO_SECRET_KEY'='django-insecure-321-do-not-use-this!!!'
...
... and then use a systemd unit file for a mock production environment ...
...
[Service]
Environment='DJANGO_SECRET_KEY'='django-insecure-321-do-not-use-this!!!'
...
urls_reuse
In your project root URLconf, use like so:
urlpatterns = [
path('', include('djinntoux.dproj.urls_reuse')),
...
]
Abstract Models
As an example in a models.py file:
from djinntoux.abstract import EditLink, Timestamps, UUIDpk7
...
class Account(Timestamps, EditLink):
EditLink
Set ADMIN_PATH in project settings (do not add a leading slash), e.g. to keep the Django default path without using an environment variable:
ADMIN_PATH = 'admin/'
Then in templates you can use like so:
<a target="_blank" href="{{ obj.get_edit_path }}">Edit</a>
Custom Users App
In project settings add djinntoux.users to INSTALLED_APPS and set AUTH_USER_MODEL = 'zy_users.User'
The main app files are mostly copied verbatim from upstream, tweaked to replace the stock first_name and last_name conventions from upstream with slightly more international options, lightly inspired by the Cookiecutter Django project.
Renames
In project settings make sure INSTALLED_APPS reflects something akin to this:
'djinntoux.renames.AuthRenamedConfig',
# 'django.contrib.auth',
# https://docs.djangoproject.com/en/dev/ref/contrib/sites/
# 'django.contrib.sites',
'djinntoux.renames.SitesRenamedConfig',
Scraping
from djinntoux.scraping import get_host_and_title
Then use like so:
def save(self, *args, **kwargs):
if not self.link_title:
self.link_title = get_host_and_title(self)[1]
super(Link, self).save(*args, **kwargs)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djinntoux-0.0.4.2.tar.gz.
File metadata
- Download URL: djinntoux-0.0.4.2.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ba92b83a115648f4b0b40042a912f132470d66636aafbfdfab23a1465354f73
|
|
| MD5 |
93b3c9ff67e3e3dbf21f3b5bac586461
|
|
| BLAKE2b-256 |
2fcddc45c796d21fa8be6969adf38af8cc238b0c865f42ede25b35f7a2602d46
|
File details
Details for the file djinntoux-0.0.4.2-py3-none-any.whl.
File metadata
- Download URL: djinntoux-0.0.4.2-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65c6bbd68a41fee01a1b004c36af2f4560da23386d3ab1a272ae331b9b98c7e7
|
|
| MD5 |
d4b977a0bddbcc6c7ed5e94a55fb6e13
|
|
| BLAKE2b-256 |
c5fabad603a3a4c627a9f0ab3243a8074817609904248aea61993c675fb980f4
|