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: DjangoBridge` header to all "GET" and "POST" requests so you no longer have to pass in `HTTP_X_REQUESTED_BY="DjangoBridge"` keyword argument.
- Customises the `assertRedirects` method 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!
python
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](https://github.com/orgs/django-bridge/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 https://github.com/django-bridge/django-bridge/pull/64
* Add support for Python 3.13 and Django 5.1 by kaedroho in https://github.com/django-bridge/django-bridge/pull/65
* Implement a Metadata type by kaedroho in https://github.com/django-bridge/django-bridge/pull/23
* RenderFrame component by kaedroho in https://github.com/django-bridge/django-bridge/pull/24
* Add an NPM package for Next.js by kaedroho in https://github.com/django-bridge/django-bridge/pull/67
* Implement pushMessages with a reducer by kaedroho in https://github.com/django-bridge/django-bridge/pull/75
* Delete packages/create-django-bridge directory by kaedroho in https://github.com/django-bridge/django-bridge/pull/78
**Full Changelog**: https://github.com/django-bridge/django-bridge/compare/v0.3.2...v0.4.0