Skip to content

Commit 30717ad

Browse files
authored
Update README.md
1 parent ddf8059 commit 30717ad

File tree

1 file changed

+21
-65
lines changed

1 file changed

+21
-65
lines changed

README.md

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11

2-
# WOLFx Admin Configuration
2+
# Welcome to the WOLFx Admin Configuration repository! 🚀
3+
WOLFx Admin configuration is created to improve the developer experience by simplifying the process of registering models in the admin site. This powerful tool is designed to automate admin registrations but it does not compromise the features that Django's default admin site provides. You can control the admin interface directly from your `models.py` file using a simple `admin_meta` dictionary. This approach eliminates the need for repetitive tasks associated with traditional model registration and allows for direct control over the admin interface, keeping your configurations closely tied to your model definitions.
34

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-
6-
## Usage
5+
## Key Features
6+
1. **Automated Model Registration: Automatically register your models in the Django admin site without the hassle of manually creating admin classes.**
7+
2. **Direct Control from Models: Manage your admin configurations right next to your model definitions using the admin_meta dictionary.**
8+
3. **Maintains Django Admin Features: Retain all the robust features offered by Django's default admin site while enjoying the benefits of simplified management.**
79

10+
## Usage
811
1. **Place the code in the `admin.py` file of your Django application.**
912
2. **Adjust the configuration constants as needed.**
1013
3. **Define `admin_meta` in your models to customize the admin interface.**
1114

12-
## Example Model Configuration 🛠️
15+
## NOTE: Configuration Constants 📌
16+
- `admin.site.site_header`: Sets the header for the admin site.
17+
- `exempt`: A list of model names that should not be registered with the admin. Note that the model_name should be used and not model itself, to understand better uncomment the `print(model_name + ' ' + str(model))` in the second last line of the code to see what is the actual model_name of your model
18+
- `global_app_name`: The name of the application. This constant determines from which app it needs to pull the models for auto-registration. As every app has its admin.py, this constant's value should be the name of its own app. For example if your app name is `web` and the admin.py belongs to this app then the value of this constant should be `web`
1319

20+
## Example Model Configuration 🛠️
1421
Here's an example of how you can define your models to leverage the dynamic admin interface:
1522

1623
```python
@@ -77,17 +84,15 @@ class BlogImage(CommonModel):
7784
```
7885

7986
### Using `admin_meta` Dictionary
80-
81-
You can control the admin interface directly from your `models.py` using the `admin_meta` dictionary. Here are some key attributes you can define:
87+
You can control the admin interface directly from your `models.py` using the `admin_meta` dictionary. Here are some key attributes you can define but are not limited to:
8288

8389
- **`list_display`**: Specify fields to be displayed in the list view.
8490
- **`list_editable`**: Fields that can be edited directly in the list view.
8591
- **`list_filter`**: Fields to filter the list view.
8692
- **`inline`**: Define inline models to be displayed.
8793

8894
### Example with JSONField Schema
89-
90-
If you have a JSONField in your model, you can customize its form field using a schema:
95+
If you have a JSONField in your model, you can customize its form field using a schema, note that this makes use of another [open-source project](https://github.com/json-editor/json-editor) and in this version, it's been muted:
9196

9297
```python
9398
class MyModel(models.Model):
@@ -123,7 +128,6 @@ class MyModel(models.Model):
123128
```
124129

125130
### JSON Editor Widget
126-
127131
The `JsonEditorWidget` class is used to render JSON fields with a user-friendly JSON editor:
128132

129133
```python
@@ -156,63 +160,15 @@ class JsonEditorWidget(widgets.Widget):
156160
''')
157161
```
158162

159-
## Note 📌
160-
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.
163+
## What is WOLFx?
164+
[WOLFx Digital Agency](https://wolfx.io) is a premier IT development company located in the financial capital of India, Mumbai. We specialize in delivering cutting-edge technology solutions and IT services, catering to businesses across various domains and helping them thrive in a digital landscape. Our services include custom software development, web and mobile application development, IT consulting, IT Outsourcing/Staffing, and Digital transformation.
210165

211-
## Dynamic App Registrations
166+
In addition to our commercial endeavors, WOLFx Digital Agency is deeply committed to the open-source community. We actively contribute to open-source projects, sharing our expertise and innovations with the wider tech community.
212167

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.
168+
## Contribution
169+
We welcome contributions to improve and expand the capabilities of WOLFx Admin Configuration. Please feel free to submit issues, feature requests, or pull requests.
214170

215-
## Media
171+
## License
172+
This project is licensed under the MIT License. See the LICENSE file for details.
216173

217-
Custom media files can be included using the Media class.
218174

0 commit comments

Comments
 (0)