**Date:** August 24, 2023
I'm excited to introduce version v0.3.0 of Django Ninja CRUD. This release has been one of my most ambitious, encompassing approximately 70 pull requests filled with new features, refinements, fixes, and more. Here's a breakdown of what's new:
π Highlights
- **Revamped Test Suite**: Undertook a major overhaul of the test suite to introduce new components like `RequestComposer` and enforce `TestCase` inheritance for `ModelViewSetTest` subclasses. These changes bring robustness and intuitiveness to our testing environment.
- **Introduction of `PartialUpdateModelView`**: The new `PartialUpdateModelView` class allows for more precise updates, simplifying and enhancing your data manipulation workflows (85, 129).
- **UX-Focused List and Create Model Views**: Improved user experience by adopting Django's `verbose_name` in list and create views, making the interface more readable and user-friendly (167).
- **Comprehensive Refactoring**: Conducted a sweeping code clean-up and restructuring for improved maintainability and future development.
- **First Complete Version of View Documentation**: Accomplished a significant milestone by providing comprehensive documentation for all views, serving as a detailed guide for users and contributors alike ([available here](https://github.com/hbakri/django-ninja-crud/wiki)).
β¨ New Features
- **Old Instance Parameter in Save Hooks**: Added `old_instance` parameter to `pre_save` and `post_save` hooks for more complex business logic during save operations (45).
- **List Type Support for Testing Suite**: Enhanced the testing suite to support attributes of the list type (47).
- **Views and Tests Matching Validation**: Introduced validation to ensure that for each view, a corresponding test exists (70).
- **TestCase Enforced for `ModelViewSetTest` Subclasses**: Now requiring that any subclass of `ModelViewSetTest` must also inherit from Django's `TestCase` (73).
- **Type Verification for Test Class Attributes**: Implemented type verifications for `ModelViewSetTest` class attributes to ensure robust and reliable tests (81).
- **Partial Updates with `PartialUpdateModelView `**: Enabled partial updates to models using the new `PartialUpdateModelView ` class (85, 129).
- **Type Verification for `ModelViewSet` Class Attributes**: Added type verifications to ensure runtime safety and reduce errors due to type mismatches (90).
- **Router Customization via `router_kwargs`**: Introduced the `router_kwargs` attribute for customizing Django Ninja's `Router` attributes, providing more control over API routes (93).
- **Custom Queryset Validation in Retrieve View**: Added `queryset_getter` validator for `RetrieveModelView` for more complex queries and added validation (157).
- **User-Friendly Model Naming in List and Create Views**: Switched to using Django's `verbose_name` for a more readable and user-friendly presentation in list and create views (167).
π οΈ Refactorings
- **Codebase Organization and File Structure**: Split `AbstractModelView` and `ModelViewSet` classes into separate files to enhance code organization (71, 54).
- **Improvements in Test Class Definitions**: Introduced `RequestComposer` and `TestAssertionHelper` for a more robust and comprehensive testing environment, and employed attribute names for unique test method naming in `ModelViewSetTest` (49, 80, 57, 54, 52, 77, 78).
- **Attribute Renaming and Removal for Test Classes**: Removed redundant attributes like `client`, `name`, `model_view_set_class`, and `urls_prefix` from `AbstractModelViewTest`, and renamed attributes to better reflect their roles such as changing `test_case` to `model_view_set_test` (60, 58, 78, 77).
- **Url Prefix and Base Path Terminology**: Renamed methods and attributes related to URL prefixes to align with the more general term `base_path` (89, 87).
- **Schema Definitions and Type Handling**: Added and renamed various type aliases for better code readability and context understanding, and renamed schema generation methods to better reflect their functionalities (181, 146, 148, 130).
- **Streamlining of Model Views**: Removed redundant and unused attributes and methods such as `related_model`, and introduced new methods like `_configure_route` and `_save_model` for better code separation (172, 154, 169, 137, 135).
- **Clarity in Naming and Functionality**: Renamed several key attributes and methods, such as `instance_builder` to `model_factory`, to provide a more intuitive understanding (190, 129, 61).
π Bug Fixes
- **Badge URL in README**: Fixed the downloads badge URL in README (156).
- **Guide File Order in Documentation Sidebar**: Resolved an issue where the files in the documentation sidebar were not in the correct order (124).
- **Type Annotation for `model_view_set_class` Attribute**: Fixed incorrect type annotations for the `model_view_set_class` attribute in `ModelViewSetTest` class (68).
- **Save and Delete Hooks Typing**: Resolved type-related issues in the `save` and `delete` hooks to improve code quality and reliability (44).
π Documentation
- **Updated README**: The README has been updated to reflect the latest changes and offer clearer guidance (193, 185).
- **In-depth View Docstrings**: Improved and added detailed docstrings for various views, enhancing the inline documentation (180, 178, 174, 164, 162, 159, 110, 109, 108).
- **Home Page Documentation**: Added a Home page to the documentation (183).
π Acknowledgments
Up until this point, the journey of developing and maintaining this open-source package has been a solo endeavor. However, the essence of open-source is community, and I'm elated to announce that this release marks a significant milestoneβour community is growing!
Welcome New Contributors!
In this release, I'm honored to welcome our very first external contributors to the project. Your active involvement not only enriches the codebase but also amplifies the spirit of collaborative development.
- **chengfangho**: Your refactoring, which renamed the `ModelViewSet` class attribute from `model` to `model_class`, has made the code more maintainable and intuitive (61).
- **lucasrcezimbra**: Your feature introducing `router_kwargs` adds a new layer of customization and flexibility to Django-Ninja's Router attributes. This is a critical enhancement that users will find extremely beneficial (93).
- **kuramen**: And a special acknowledgment goes to my friend and colleague, who made the project more visually engaging by integrating both the project and Django-Ninja logos into our README. Kuramen, your creative touch inspired the idea for the logo and made a significant impact on how newcomers perceive our project (92).
New contributors, your additions are invaluable and warmly welcomed. The project is all the richer for your involvement, and I'm eager to see how your future contributions will continue to enhance our growing community.