Version 0.4 - Unit testing improvements, Next.js support, and bug fixes
What's Changed
Improvements for unit testing
This release brings a couple of improvements to simplify writing unit tests for Django bridge views.
Firstly, we've added a custom TestCase class to make testing Django Bridge views feel more similar to testing regular Django views. This class:
- Adds the
X-Requested-By: DjangoBridgeheader to all "GET" and "POST" requests so you no longer have to pass inHTTP_X_REQUESTED_BY="DjangoBridge"keyword argument. - Customises the
assertRedirectsmethod to work with Django-bridge redirect responses (which are converted from 302 to 200 to allow the frontend library to process them properly)
Secondly, Response objects now include the unserialised props making it easier to assert against serialized Python objects (like forms).
For example, you can now use assertFormError in your tests!
# tests.py
class TestMyForm(TestCase):
def test_post_invalid(self):
response = self.client.post("/form", {})
self.assertFormError(
response.props["form"], "required_field", "This field is required."
)Initial Next.js support
We've created a new NPM package called @django-render/next to allow creating static websites that are backed by Django.
This includes the basic utilities required to render a django-render response with Next.js, including converting objects like forms into JS objects. It currently excludes context providers, <Link> and <Form> components (use the next.js provided versions instead) and overlays.
There's still a lot of work to do here, so keep your eyes on this space. Please reach out in discussions if you'd like to use next.js or contribute to improve its support!
Full list of significant changes
- Add some test utilities by @kaedroho in #64
- Add support for Python 3.13 and Django 5.1 by @kaedroho in #65
- Implement a Metadata type by @kaedroho in #23
- RenderFrame component by @kaedroho in #24
- Add an NPM package for Next.js by @kaedroho in #67
- Implement pushMessages with a reducer by @kaedroho in #75
- Delete packages/create-django-bridge directory by @kaedroho in #78
Full Changelog: v0.3.2...v0.4.0