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.
- Adjusted
object_list.htmltemplate to be more in line with neapolitan's upstream template.
- Removed use of
django.utils.itercompatfrom templatetags in favor ofisinstancecheck.
- 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.CRUDViewlist 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.WwwRedirectMiddlewarefor 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_byfield toWithHistoryabstract model with a relation to a application'sUsermodel to track the source of the change through time. This will require a run ofmakemigrationsandmigrateon any model inheriting fromWithHistory.
- Bumped
django-twc-packagetemplate version to v2024.27.
- The entirety of the
WithHistoryabstract 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_partialsflag. This is a breaking change as previously template partials were enabled by default. This has caused downstream issues when trying to adoptCRUDViewon projects that use HTMX but have no partial template needs (at the moment).
- Added
format_number_no_roundfunction 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-packagetemplate version to v2024.24.
- Added a
{% startswith %}utility templatetag filter. - Added a generic type argument to
DatePaginator.
date_page_rangeis now explicitly a required argument toDatePaginator. Previously, it was allowed to beNone, but would still fail ifdate_rangewas not passed in instead.date_rangehas been removed as an argument, see below.- Types within
DatePaginatorhave been adjusted.
- Removed the
date_rangeargument fromDatePaginator, a few versions past when I meant to.
- Fixed a bug in
CRUDView.get_context_dataif the role had no specific context data method defined.
- Introduced dynamic role-based context data in
CRUDViewwith newget_role_context_datamethod through role-specific context methods (e.g.,get_create_context_data) to add custom context data scoped only to that role.
get_context_datanow incorporates role-specific context data by callingget_role_context_data.
- Added support for specifying primary filters on
CRUDViewvia afilterset_primary_fieldsclass 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 theFilterSetreturned byCRUDView.get_filtersetrelated to the active filters set on the view in the current request.
- Added override of
get_paginate_bytoCRUDViewin order to accept arbitraryargsandkwargs. This is due to the differences in the method betweenneapolitan.views.CRUDViewanddjango_tables2.views.SingleTableMixin. By making this change, it simplifies the code path in theCRUDView.listmethod a tiny bit.
- Added
django_twc_toolbox.urls.reverseanddjango_twc_toolbox.urls.reverse_lazywhich take Django's built-inreverseand adds the ability to urlencode query parameters and fragments.
- Fixed pagination and ordering of
CRUDView.object_listwhen atable_classis provided.
- Corrected check for HTMX request (again!).
- Corrected check in
django_twc_toolbox.crud.CRUDView.get_template_namesfor if anHttpRequestis 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_classandtable_dataclass 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.sentrynow correctly type hinted.
- Added
django_twc_toolbox.crudapp. 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
CRUDViewthat inherits fromneapolitan.views.CRUDViewwith 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.neapolitanis 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. (neapolitanitself returns aModelinstance'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.txtand.well-known/security.txtviews.
- Removed support for Python 3.8 and 3.9.
- Added
list_templatesmanagement command, inspired by this post from Carlton Gibson (@carltongibson). - Added
copy_templatemanagement command, taken from this project by Andrew Miller (@nanorepublica). - Added
ruffto 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.StackedInlineandadmin.TabularInline.
- Added a
WithHistoryabstract model for integratingdjango-simple-historyHistoricalRecords. - Added custom
createsuperusermanagement command to allow for resetting an existing superuser's password in development whenDEBUG=True.
- Added a
CuidFieldand 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.typedadded to the project.
- Now using v2024.27 of
django-twc-package.
- Added the
page_date_rangeargument to theDatePaginator, taking the place of the existingdate_rangeargument. 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
DatePaginatorclass to use thepage_date_rangeargument instead of the deprecateddate_rangeargument. DatePage.min_date,DatePage.max_date, andDatePage.date_rangeare nowcached_propertyattributes instead of being set in the__init__method.- Now using
django-twc-packagetemplate for repository and package structure.
- The
date_rangeargument of theDatePaginatorclass is now deprecated. It will be removed in version 0.4.0.
- Removed the
orphanskwarg 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_dateandDatePage.max_datenow return the correct dates for the page.DatePage.min_datereturns the oldest date andDatePage.max_datereturns the newest date.DatePage.date_rangenow returns the correct range of dates for the page.
DatePaginatorandDatePageclasses, extending Django's built-inPaginatorandPageclasses, 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
TimeStampedabstract model for addingcreated_atandupdated_atfields to models.
- Josh Thomas josh@joshthomas.dev (maintainer)