Plugin & Addon Development
Ralph is designed to be extended through plugins and addons without modifying the core codebase. This guide covers different extension mechanisms and best practices.Extension Methods
Ralph supports several ways to extend functionality:- Custom admin views and tabs - Add new pages to existing models
- External Django apps - Integrate standalone Django applications
- Entry point hooks - Override specific behaviors via setup.py entry points
- Custom filters - Add specialized search and filter capabilities
- Signals and receivers - React to events in Ralph
Custom Admin Views
Adding Tabs to Detail Views
Add custom tabs to model detail pages usingRalphDetailView or RalphDetailViewAdmin:
myapp/templates/myapp/asset_usage_report.html):
docs/development/addons.md:14-64
Using RalphDetailViewAdmin
For standard admin-style tabs with inlines:docs/development/addons.md:39-51
Registering Views
Method 1: Via Admin Class (Internal Development)
Use when developing directly in Ralph:docs/development/addons.md:77-96
Method 2: Via Decorator (External Plugins)
Recommended for external applications and plugins:docs/development/addons.md:98-114
Template Locations
Templates must be in one of these locations:<model_name>/<view_name>.html<app_label>/<model_name>/<view_name>.html
BackOfficeAsset model with view name monitoring:
backofficeasset/monitoring.htmlback_office/backofficeasset/monitoring.html
docs/development/addons.md:66-76
Entry Point Hooks
Override Ralph’s internal methods using setuptools entry points.Defining Entry Points
In your plugin’ssetup.py:
docs/development/addons.md:128-146, src/ralph/setup.py:37-53
Implementing Hooks
In your plugin code (myplugin/helpers.py):
docs/development/addons.md:128-165
Available Hooks
| Hook Name | Description | Parameters | Return Value |
|---|---|---|---|
back_office.transition_action.email_context | Email templates for transitions | transition_name: str | EmailContext(subject, body) |
account.views.get_asset_list_class | Custom asset list view | - | View class |
ralph.cloud_sync_processors | Cloud synchronization processor | - | Processor endpoint |
docs/development/addons.md:149-153
Configuring Hooks
Activate hooks via environment variables:docs/development/addons.md:154-165
External Django Apps
Integrate standalone Django applications with Ralph.Creating a Plugin App
Project structure:App Configuration
ralph_monitoring/apps.py:
Models
ralph_monitoring/models.py:
Admin Integration
ralph_monitoring/admin.py:
URL Configuration
ralph_monitoring/urls.py:
Installation
setup.py:
Custom Filters
Create specialized admin filters:Signals and Event Handlers
React to events in Ralph:Best Practices
1. Use Decorators for External Plugins
Always use@register_extra_view for external plugins instead of modifying admin classes:
2. Namespace Your URLs and Templates
Avoid conflicts by using consistent naming:3. Use Entry Points for Behavior Changes
Don’t monkey-patch Ralph code. Use entry points:4. Follow Ralph Conventions
- Inherit from Ralph base classes (
RalphAdmin,RalphDetailView) - Use Ralph mixins (
TimeStampMixin,AdminAbsoluteUrlMixin) - Follow Ralph’s permission system
- Use Ralph’s form and widget classes
5. Handle Dependencies
Declare Ralph as a dependency:6. Provide Documentation
Include README with:- Installation instructions
- Configuration options
- Usage examples
- Dependencies
- License information
Example Plugin Package
Complete example of a monitoring plugin:- Custom tab on asset detail pages showing real-time metrics
- Admin interface for historical metrics
- API endpoint for pushing metrics from external systems
- Dashboard view for monitoring overview
- Signal handlers for automatic metric collection
Next Steps
- Review RalphAdmin customization for admin features
- Learn about Transitions for workflow integration
- Explore Custom Fields for data extension
- Read the API documentation for REST API integration