Skip to main content

Boxine - bx_django_utils

Various Django utility functions

Quickstart

pip install bx_django_utils

Existing stuff

Here only a simple list about existing utilities. Please take a look into the sources and tests for deeper informations.

bx_django_utils.approve_workflow

Base model/admin/form classes to implement a model with draft/approve versions workflow

bx_django_utils.approve_workflow.admin

bx_django_utils.approve_workflow.forms

bx_django_utils.approve_workflow.models

bx_django_utils.data_types.gtin

ModelField, FormField and validators for GTIN/UPC/EAN numbers

bx_django_utils.data_types.gtin.form_fields
bx_django_utils.data_types.gtin.model_fields
bx_django_utils.data_types.gtin.validators

bx_django_utils.dbperf.cursor

bx_django_utils.dbperf.query_recorder

  • SQLQueryRecorder() - A context manager that allows recording SQL queries executed during its lifetime.

bx_django_utils.filename

bx_django_utils.humanize.pformat

  • pformat() - Better pretty-print-format using DjangoJSONEncoder with fallback to pprint.pformat()

bx_django_utils.humanize.time

  • human_timedelta() - Converts a time duration into a friendly text representation. (X ms, sec, minutes etc.)

bx_django_utils.json_utils

  • make_json_serializable() - Convert value to a JSON serializable value, with convert callback for special objects.
  • to_json() - Convert value to JSON via make_json_serializable() and DjangoJSONEncoder()

bx_django_utils.models.color_field

  • ColorModelField() - Hex color model field, e.g.: "#0055ff" (It's not a html color picker widget)
  • HexColorValidator() - Hex color validator (seven-character hexadecimal notation, e.g.: "#0055ff")

bx_django_utils.models.manipulate

Utilities to manipulate objects in database via models:

  • CreateOrUpdateResult() - Result object returned by create_or_update2() with all information about create/save a model.
  • InvalidStoreBehavior() - Exception used in create_or_update() if "store_behavior" contains not existing field names.
  • create() - Create a new model instance with optional validate before create.
  • create_or_update() - Create a new model instance or update a existing one. Deprecated! Use: create_or_update2()
  • create_or_update2() - Create a new model instance or update a existing one and returns CreateOrUpdateResult instance

bx_django_utils.models.timetracking

bx_django_utils.stacktrace

bx_django_utils.templatetags.humanize_time

  • human_duration() - Verbose time since template tag, e.g.: <span title="Jan. 1, 2000, noon">2.0 seconds</span>

bx_django_utils.test_utils

Utilities / helper for writing tests.

bx_django_utils.test_utils.assert_queries

  • AssertQueries() - Assert executed database queries: Check table names, duplicate/similar Queries.

bx_django_utils.test_utils.datetime

bx_django_utils.test_utils.html_assertion

bx_django_utils.test_utils.model_clean_assert

bx_django_utils.test_utils.users

bx_django_utils.view_utils.dynamic_menu_urls

  • DynamicViewMenu() - Simple storage for store information about views/urls to build a menu.

developing

To start developing e.g.:

~$ git clone https://github.com/boxine/bx_django_utils.git
~$ cd bx_django_utils
~/bx_django_utils$ make
help                 List all commands
install-poetry       install or update poetry
install              install via poetry
update               Update the dependencies as according to the pyproject.toml file
lint                 Run code formatters and linter
fix-code-style       Fix code formatting
tox-listenvs         List all tox test environments
tox                  Run pytest via tox with all environments
tox-py36             Run pytest via tox with *python v3.6*
tox-py37             Run pytest via tox with *python v3.7*
tox-py38             Run pytest via tox with *python v3.8*
tox-py39             Run pytest via tox with *python v3.9*
pytest               Run pytest
pytest-ci            Run pytest with CI settings
publish              Release new version to PyPi
makemessages         Make and compile locales message files
start-dev-server     Start Django dev. server with the test project
clean                Remove created files from the test project (e.g.: SQlite, static files)

You can start the test project with the Django developing server, e.g.:

~/bx_django_utils$ make start-dev-server

This is a own manage command, that will create migrations files from our test app, migrate, collectstatic and create a super user if no user exists ;)

If you like to start from stretch, just delete related test project files with:

~/bx_django_utils$ make clean

...and start the test server again ;)

License

MIT. Patches welcome!

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bx_django_utils-8.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bx_django_utils-8-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file bx_django_utils-8.tar.gz.

File metadata

  • Download URL: bx_django_utils-8.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.9 Linux/5.14.0-4-amd64

File hashes

Hashes for bx_django_utils-8.tar.gz
Algorithm Hash digest
SHA256 f77eeffc737938f1e72586e2e1605614e3a26609f6d04d76c4bc893ba231e979
MD5 fd85c99527b8ea8eaaf031ebb2b1f8a2
BLAKE2b-256 1e0cff3d5a5c26c498b48bf149a2a08540a5812c585c9bfb59f4e303198aa123

See more details on using hashes here.

File details

Details for the file bx_django_utils-8-py3-none-any.whl.

File metadata

  • Download URL: bx_django_utils-8-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.9 Linux/5.14.0-4-amd64

File hashes

Hashes for bx_django_utils-8-py3-none-any.whl
Algorithm Hash digest
SHA256 20b083e4ac702c3e76ac31714daf61cdf439932a0e045c15e77d4aef87de260e
MD5 61fb89a7a2b4384aef211e2052b93fa6
BLAKE2b-256 031d87d563510ccf21fe3a23d219bb3da50dad349e67415b188792dbe0f67b30

See more details on using hashes here.

Release history Release notifications | RSS feed

101

2 files

100

2 files

99

2 files

98

2 files

97

2 files

96

2 files

95

2 files

94

2 files

93

2 files

92

2 files

91

2 files

90

2 files

89

2 files

88

2 files

87

2 files

86

2 files

85

2 files

84

2 files

83

2 files

82

2 files

81

2 files

79

2 files

78

2 files

77

2 files

76

2 files

75

2 files

74

2 files

72

2 files

71

2 files

70

2 files

69

2 files

68

2 files

67

2 files

66

2 files

65

2 files

64

2 files

63

2 files

62

2 files

61

2 files

60

2 files

59

2 files

58

2 files

57

2 files

56

2 files

55

2 files

54

2 files

53

2 files

52

2 files

51

2 files

50

2 files

49

2 files

48

2 files

47

2 files

46

2 files

45

2 files

44

2 files

43

2 files

42

2 files

41

2 files

40

2 files

39

2 files

38

2 files

37

2 files

36

2 files

35

2 files

34

2 files

33

2 files

32

2 files

31

2 files

30

2 files

29

2 files

28

2 files

27

2 files

26

2 files

25

2 files

24

2 files

23

2 files

22

2 files

21

2 files

20

2 files

19

2 files

18

2 files

17

2 files

16

2 files

15

2 files

14

2 files

13

2 files

12

2 files

11

2 files

10

2 files

9

2 files

This release

8 This release

2 files

7

2 files

6

2 files

5

2 files

4

2 files

3

2 files

2

2 files

1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page