|
3 | 3 |
|
4 | 4 | This repository contains the configuration for the WOLFx Admin interface. Below are the instructions and details to understand and extend the functionality of the admin interface. |
5 | 5 |
|
6 | | -## Configuration Constants |
7 | | - |
8 | | -- `admin.site.site_header`: Sets the header for the admin site. |
9 | | -- `exempt`: A list of model names that should not be registered with the admin. |
10 | | -- `global_app_name`: The name of the application. |
11 | | - |
12 | | -## GenericStackedAdmin Class |
13 | | - |
14 | | -This class is used for inline models in the admin interface. |
15 | | - |
16 | | -### get_formset |
17 | | - |
18 | | -This method ensures the field order is correct for inlines. |
19 | | - |
20 | | -## GenericAdmin Class |
21 | | - |
22 | | -This class provides a dynamic admin interface for models. |
23 | | - |
24 | | -### __init__ |
25 | | - |
26 | | -- Initializes the admin interface for the model. |
27 | | -- Registers inlines and actions dynamically based on model attributes. |
28 | | - |
29 | | -### formfield_for_dbfield |
30 | | - |
31 | | -- Customizes the form field for JSONField using a schema if defined in the model's admin_meta. |
32 | | - |
33 | | -### get_fieldsets |
34 | | - |
35 | | -- Defines fieldsets for the admin interface. |
36 | | -- If fieldsets are defined in admin_meta, those are used. |
37 | | - |
38 | | -### get_readonly_fields |
39 | | - |
40 | | -- Returns a list of non-editable fields. |
41 | | - |
42 | | -### add_action |
43 | | - |
44 | | -- Adds an action to the admin interface. |
45 | | - |
46 | | -### register_inlines |
47 | | - |
48 | | -- Registers inlines for the admin interface. |
49 | | - |
50 | | -### add_inline |
51 | | - |
52 | | -- Adds an inline model to the admin interface. |
53 | | - |
54 | | -## Dynamic App Registrations |
55 | | - |
56 | | -The models from the specified application are dynamically registered to the admin interface unless they are in the exempt list or have 'histor' in their name. |
57 | | - |
58 | | -## Media |
59 | | - |
60 | | -Custom media files can be included using the Media class. |
61 | | - |
62 | 6 | ## Usage |
63 | 7 |
|
64 | 8 | 1. **Place the code in the `admin.py` file of your Django application.** |
@@ -215,3 +159,60 @@ class JsonEditorWidget(widgets.Widget): |
215 | 159 | ## Note 📌 |
216 | 160 |
|
217 | 161 | Make sure to replace `'web'` with your actual app name in the `global_app_name` variable. |
| 162 | + |
| 163 | +## Configuration Constants |
| 164 | + |
| 165 | +- `admin.site.site_header`: Sets the header for the admin site. |
| 166 | +- `exempt`: A list of model names that should not be registered with the admin. |
| 167 | +- `global_app_name`: The name of the application. |
| 168 | + |
| 169 | +## GenericStackedAdmin Class |
| 170 | + |
| 171 | +This class is used for inline models in the admin interface. |
| 172 | + |
| 173 | +### get_formset |
| 174 | + |
| 175 | +This method ensures the field order is correct for inlines. |
| 176 | + |
| 177 | +## GenericAdmin Class |
| 178 | + |
| 179 | +This class provides a dynamic admin interface for models. |
| 180 | + |
| 181 | +### __init__ |
| 182 | + |
| 183 | +- Initializes the admin interface for the model. |
| 184 | +- Registers inlines and actions dynamically based on model attributes. |
| 185 | + |
| 186 | +### formfield_for_dbfield |
| 187 | + |
| 188 | +- Customizes the form field for JSONField using a schema if defined in the model's admin_meta. |
| 189 | + |
| 190 | +### get_fieldsets |
| 191 | + |
| 192 | +- Defines fieldsets for the admin interface. |
| 193 | +- If fieldsets are defined in admin_meta, those are used. |
| 194 | + |
| 195 | +### get_readonly_fields |
| 196 | + |
| 197 | +- Returns a list of non-editable fields. |
| 198 | + |
| 199 | +### add_action |
| 200 | + |
| 201 | +- Adds an action to the admin interface. |
| 202 | + |
| 203 | +### register_inlines |
| 204 | + |
| 205 | +- Registers inlines for the admin interface. |
| 206 | + |
| 207 | +### add_inline |
| 208 | + |
| 209 | +- Adds an inline model to the admin interface. |
| 210 | + |
| 211 | +## Dynamic App Registrations |
| 212 | + |
| 213 | +The models from the specified application are dynamically registered to the admin interface unless they are in the exempt list or have 'histor' in their name. |
| 214 | + |
| 215 | +## Media |
| 216 | + |
| 217 | +Custom media files can be included using the Media class. |
| 218 | + |
0 commit comments