All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project attempts to adhere to Semantic Versioning.
- Remove
WithHistory.changed_by
. This was introduced due to a misread of the django-simply-history documentation and is unneeded.
- Pagination in the
django_twc_toolbox.crud.views.CRUDView
list view now respects whether the view is using django-tables2 or the falling back to the default provided by neapolitan.
- A middleware
django_twc_toolbox.middleware.WwwRedirectMiddleware
for redirecting any request from a "www." subdomain to the bare domain. All credit to Adam Johnson -- How to Make Django Redirect WWW to Your Bare Domain - Adam Johnson. - Now supporting Django 5.1.
- Added a
changed_by
field toWithHistory
abstract model with a relation to a application'sUser
model to track the source of the change through time. This will require a run ofmakemigrations
andmigrate
on any model inheriting fromWithHistory
.
- Bumped
django-twc-package
template version to v2024.27.
- The entirety of the
WithHistory
abstract model is now behind the check to see if django-simple-history is installed. Thanks to @Tobi-De for the bug report (#107).
- Template partials are now behind a
CRUDView.enable_template_partials
flag. This is a breaking change as previously template partials were enabled by default. This has caused downstream issues when trying to adoptCRUDView
on projects that use HTMX but have no partial template needs (at the moment).
- Added
format_number_no_round
function to handle formatting of numbers with a specified number of decimal places while trimming excess trailing zeros or adding zeros as needed. - Support for Python 3.13.
- Bumped
django-twc-package
template version to v2024.24.
- Added a
{% startswith %}
utility templatetag filter. - Added a generic type argument to
DatePaginator
.
date_page_range
is now explicitly a required argument toDatePaginator
. Previously, it was allowed to beNone
, but would still fail ifdate_range
was not passed in instead.date_range
has been removed as an argument, see below.- Types within
DatePaginator
have been adjusted.
- Removed the
date_range
argument fromDatePaginator
, a few versions past when I meant to.
- Fixed a bug in
CRUDView.get_context_data
if the role had no specific context data method defined.
- Introduced dynamic role-based context data in
CRUDView
with newget_role_context_data
method through role-specific context methods (e.g.,get_create_context_data
) to add custom context data scoped only to that role.
get_context_data
now incorporates role-specific context data by callingget_role_context_data
.
- Added support for specifying primary filters on
CRUDView
via afilterset_primary_fields
class attribute. Sometimes you have a model and corresponding crud view that has a bunch of filters attached to it. Rather than show all filters or show none and hide them behind a 'Show Filters' button, this allows you to have a handful of primary filters with the rest of the filters set as secondary. This way, you can always show the primary filters, but hide the secondary ones. - Added an extra method (
is_active()
) and property (active_filters
) to theFilterSet
returned byCRUDView.get_filterset
related to the active filters set on the view in the current request.
- Added override of
get_paginate_by
toCRUDView
in order to accept arbitraryargs
andkwargs
. This is due to the differences in the method betweenneapolitan.views.CRUDView
anddjango_tables2.views.SingleTableMixin
. By making this change, it simplifies the code path in theCRUDView.list
method a tiny bit.
- Added
django_twc_toolbox.urls.reverse
anddjango_twc_toolbox.urls.reverse_lazy
which take Django's built-inreverse
and adds the ability to urlencode query parameters and fragments.
- Fixed pagination and ordering of
CRUDView.object_list
when atable_class
is provided.
- Corrected check for HTMX request (again!).
- Corrected check in
django_twc_toolbox.crud.CRUDView.get_template_names
for if anHttpRequest
is an HTMX request or not.
- Two new templatetag filters:
{{ variable|klass }}
and{{ variable|class_name }}
. - Support for using django-tables2 with
django_twc_toolbox.crud.CRUDView
. The view now has the option to settable_class
andtable_data
class attributes that will render the table on the list page using django-tables2. - Support for template partials in
django_twc_toolbox.crud.CRUDView
, using django-template-partials.
- Functions in
django_twc_toolbox.sentry
now correctly type hinted.
- Added
django_twc_toolbox.crud
app. Previously, we were maintaining a fork with a handful of customizations on top. The maintenance burden of keeping our fork updated with upstream has proven to be too much of a time commitment, so we are moving what little we have overridden here.- Includes a
CRUDView
that inherits fromneapolitan.views.CRUDView
with a few extra urls thrown in the template context, as well as the ability to specify different fields for the list and detail views. neapolitan.templatetags.neapolitan
is being shadowed allowing both{% object_detail %}
and{% object_list %}
to use ourCRUDView
's ability to use different fields (as mentioned above), as well as return the string version of any relatedModel
. (neapolitan
itself returns aModel
instance's primary key.) Additionally, the action links for the list view are a dictionary instead of a rendered string.
- Includes a
- Added a handful of core views: 404 and 500 error handling views and
robots.txt
and.well-known/security.txt
views.
- Removed support for Python 3.8 and 3.9.
- Added
list_templates
management command, inspired by this post from Carlton Gibson (@carltongibson). - Added
copy_template
management command, taken from this project by Andrew Miller (@nanorepublica). - Added
ruff
to dev dependency extras. - Added Sentry trace and profile sampling functionality with configurable discard rules for specific HTTP methods and paths.
- Added read only versions of
admin.StackedInline
andadmin.TabularInline
.
- Added a
WithHistory
abstract model for integratingdjango-simple-history
HistoricalRecords
. - Added custom
createsuperuser
management command to allow for resetting an existing superuser's password in development whenDEBUG=True
.
- Added a
CuidField
and extra dependencies needed to use it. Install the package withdjango-twc-toolbox[cuid]
in order to use it.
- Dropped support for Django 3.2 (EOL April 2024).
py.typed
added to the project.
- Now using v2024.27 of
django-twc-package
.
- Added the
page_date_range
argument to theDatePaginator
, taking the place of the existingdate_range
argument. This change clarifies that it represents constraining the range of dates for each page, not the entire range of dates for the paginator.
- Updated the
DatePaginator
class to use thepage_date_range
argument instead of the deprecateddate_range
argument. DatePage.min_date
,DatePage.max_date
, andDatePage.date_range
are nowcached_property
attributes instead of being set in the__init__
method.- Now using
django-twc-package
template for repository and package structure.
- The
date_range
argument of theDatePaginator
class is now deprecated. It will be removed in version 0.4.0.
- Removed the
orphans
kwarg fromDatePaginator
, which is inherited from Django's built-inPaginator
. Given its date range-based pagination, the concept of orphans, applicable to item count per page, is not super useful. If it is passed in, a warning will be issued.
DatePage.min_date
andDatePage.max_date
now return the correct dates for the page.DatePage.min_date
returns the oldest date andDatePage.max_date
returns the newest date.DatePage.date_range
now returns the correct range of dates for the page.
DatePaginator
andDatePage
classes, extending Django's built-inPaginator
andPage
classes, respectively. These new classes enable pagination based on a specified date field, making it easier to work with date-based data. Useful for applications that require handling of time-series data or chronological records, such as a blog or an event archive.
Initial release!
- Initial documentation.
- Initial tests.
- Initial CI/CD (GitHub Actions).
- A
TimeStamped
abstract model for addingcreated_at
andupdated_at
fields to models.
- Josh Thomas [email protected] (maintainer)