ViewActionMixin¶
ViewActionMixin
¶
djadmin.actions.base.ViewActionMixin
Mixin for actions that generate a full Django CBV (Pattern B).
This is for actions that redirect to a complete view (CreateView, UpdateView, FormView, DetailView, etc.) where the view is factory-generated with all logic. The action provides configuration for ViewFactory or a custom view class.
Use this for: AddAction (→ CreateView), EditRecordAction (→ UpdateView) NOT for: ChangeStatusAction, SendEmailAction (use FormActionMixin instead)
Note: This is future functionality for Milestone 3. The action itself would be passed to ViewFactory which would generate the appropriate view based on the action's view-type mixin (e.g., FormViewActionMixin, DetailViewActionMixin).
Class Attributes
| Attribute | Type | Description |
|---|---|---|
view_class |
- | Optional custom view class (bypasses factory if provided) |
view_factory |
- | Factory class to use (default: ViewFactory) |
form_class |
- | Form class to use (optional) |
fields |
- | Fields to include in form (optional) |
Method Resolution Order
djadmin.actions.base.ViewActionMixin
Attributes
| Attribute | Value | Defined in |
|---|---|---|
__annotations__ |
{'view_class': type | None, 'view_factory': type | None, ... |
djadmin.actions.base.ViewActionMixin
|
fields |
None |
djadmin.actions.base.ViewActionMixin
|
form_class |
None |
djadmin.actions.base.ViewActionMixin
|
view_class |
None |
djadmin.actions.base.ViewActionMixin
|
view_factory |
None |
djadmin.actions.base.ViewActionMixin
|
Methods
get_view_class(self) -> type
Defined in:
<class 'djadmin.actions.base.ViewActionMixin'>
Get the view class for this action.
If view_class is set, returns it directly (bypassing factory). Otherwise, uses ViewFactory to generate a view class based on the action's view-type mixin.
Returns: View class ready for .as_view()
Source code
in base.py
line 454
def get_view_class(self) -> type:
"""
Get the view class for this action.
If view_class is set, returns it directly (bypassing factory).
Otherwise, uses ViewFactory to generate a view class based on the
action's view-type mixin.
Returns:
View class ready for .as_view()
"""
# If custom view_class provided, use it directly
if self.view_class is not None:
return self.view_class
# Otherwise, use factory to generate view
from djadmin.factories import ViewFactory
factory = self.view_factory or ViewFactory()
return factory.create_view(action=self)
get_view_config(self) -> dict
Defined in:
<class 'djadmin.actions.base.ViewActionMixin'>
Get configuration dict for this action's view.
This provides action-specific configuration that can be used by the factory or custom view classes.
Returns: Dict of configuration
Source code
in base.py
line 475
def get_view_config(self) -> dict:
"""
Get configuration dict for this action's view.
This provides action-specific configuration that can be used
by the factory or custom view classes.
Returns:
Dict of configuration
"""
config = {
'model': self.model,
'model_admin': self.model_admin,
'admin_site': self.admin_site,
'action': self,
}
# Add form configuration if applicable
if self.form_class is not None:
config['form_class'] = self.form_class
if self.fields is not None:
config['fields'] = self.fields
return config
Fields
| Field | Type | Related To |
|---|---|---|
__dict__ |
getset_descriptor |
- |
__weakref__ |
getset_descriptor |
- |