# pip install django-msms-admin
Intelligent management for multiple subclass models in django's admin site.
## Install
```shell
pip install django-msms-admin
```
## Installed Classes
- DjangoMsmsModelAbstractBase
The base model must inherit from DjangoMsmsModelAbstractBase class. It provides app_label, model_name, type_name fields and auto save the values.
- DjangoMsmsAdmin
The base model admin must inherit from DjangoMsmsAdmin class.
- DjangoSubclassAdmin
All subclass models' admin must inherit from DjangoSubclassAdmin class.
## Configurations
- DjangoMsmsAdmin.subclasses
The config item is used to provide choices in **select_subclass_model_view**. If NOT provide, the system will auto find all registered subclasses. The structure of subclasses is a three-level-tree. e.g.
```python
subclasses = [{
"title": "category1",
"children": [{
"title": "category11",
"children: [
Model1,
Model2,
Model3,
]
},{
"title": "category12",
"children": [
Model4,
Model5,
Model6,
]
}]
},{
"title": "category2",
"children": [{
"title": "category21",
"children": [
Model7,
Model8,
]
},{
"title": "category22,
"children": [
Model9,
]
}]
}]
```
- DjangoMsmsModelAbstractBase.cascade_select_description
- DjangoMsmsModelAbstractBase.cascade_select_image
Config item cascade_select_description and cascade_select_image are use to display more information while you selected a subclass. cascade_select_image is url string of an image.
## Usage
**pro/settings.py**
```python
INSTALLED_APPS = [
...
'django_simple_tags',
'django_static_jquery3',
'django_msms_admin',
...
]
```
**app/model.py**
```python
from django.db import models
from django.contrib.staticfiles.templatetags.staticfiles import static
from django_msms_admin.models import DjangoMsmsModelAbstractBase
class Book(DjangoMsmsModelAbstractBase, models.Model):
title = models.CharField(max_length=64)
author = models.CharField(max_length=64)
def __str__(self):
return self.title
class ComputerBook(Book):
serial = models.CharField(max_length=64)
cascade_select_description = "These books are all about computers."
cascade_select_image = static("app/img/computer-book.jpg")
class NovelBook(Book):
country = models.CharField(max_length=64)
```
**app/admin.py**
```python
from django.contrib import admin
from django_msms_admin.admin import DjangoMsmsAdmin
from django_msms_admin.admin import DjangoSubclassAdmin
from .models import Book
from .models import ComputerBook
from .models import NovelBook
class BookAdmin(DjangoMsmsAdmin, admin.ModelAdmin):
list_display = ["title", "author", "type_name"]
list_filter = ["type_name"]
admin.site.register(Book, BookAdmin)
admin.site.register(ComputerBook, DjangoSubclassAdmin)
admin.site.register(NovelBook, DjangoSubclassAdmin)
```
## Release
### v0.1.0 2020/03/03
- First release.
### v0.1.1 2020/03/05
- Add DjangoMsmsModelAbstractBase.get_real_object method.
### v0.1.2 2020/03/06
- Fix keywords in setup.py and read requirements.txt for install_requires.
### v0.2.0 2020/03/07
- Use model's msms_category, msm_priority property to do model category and sorting.
- Rename cascade_select_description to msms_description.
- Rename cascade_select_preview_image to msms_image.
### v0.2.1 2020/09/09
- No depends on django-static-jquery3.
- Using media.css & media.js to render css/js links.
- Add LICENSE file.
### v0.2.2 2023/09/18
- Doc update.
Raw data
{
"_id": null,
"home_page": "",
"name": "django-msms-admin",
"maintainer": "Jiang Tao",
"docs_url": null,
"requires_python": "",
"maintainer_email": "jiangtao@zencore.cn",
"keywords": "django admin extentions,django msms admin",
"author": "Jiang Tao",
"author_email": "jiangtao@zencore.cn",
"download_url": "https://files.pythonhosted.org/packages/84/f1/f7ad84e8f7ec51eb051b0df05d84059c3dc6670bff4edd301dc45783a6b5/django-msms-admin-0.2.2.tar.gz",
"platform": null,
"description": "# pip install django-msms-admin\n\nIntelligent management for multiple subclass models in django's admin site.\n\n## Install\n\n```shell\npip install django-msms-admin\n```\n\n## Installed Classes\n\n- DjangoMsmsModelAbstractBase\n\n The base model must inherit from DjangoMsmsModelAbstractBase class. It provides app_label, model_name, type_name fields and auto save the values.\n\n- DjangoMsmsAdmin\n\n The base model admin must inherit from DjangoMsmsAdmin class.\n\n- DjangoSubclassAdmin\n\n All subclass models' admin must inherit from DjangoSubclassAdmin class.\n\n## Configurations\n\n- DjangoMsmsAdmin.subclasses\n\n The config item is used to provide choices in **select_subclass_model_view**. If NOT provide, the system will auto find all registered subclasses. The structure of subclasses is a three-level-tree. e.g.\n\n ```python\n subclasses = [{\n \"title\": \"category1\",\n \"children\": [{\n \"title\": \"category11\",\n \"children: [\n Model1,\n Model2,\n Model3,\n ]\n },{\n \"title\": \"category12\",\n \"children\": [\n Model4,\n Model5,\n Model6,\n ]\n }]\n },{\n \"title\": \"category2\",\n \"children\": [{\n \"title\": \"category21\",\n \"children\": [\n Model7,\n Model8,\n ]\n },{\n \"title\": \"category22,\n \"children\": [\n Model9,\n ]\n }]\n }]\n ```\n\n- DjangoMsmsModelAbstractBase.cascade_select_description\n- DjangoMsmsModelAbstractBase.cascade_select_image\n\n Config item cascade_select_description and cascade_select_image are use to display more information while you selected a subclass. cascade_select_image is url string of an image.\n\n\n## Usage\n\n**pro/settings.py**\n\n```python\nINSTALLED_APPS = [\n ...\n 'django_simple_tags',\n 'django_static_jquery3',\n 'django_msms_admin',\n ...\n]\n```\n\n**app/model.py**\n\n```python\nfrom django.db import models\nfrom django.contrib.staticfiles.templatetags.staticfiles import static\nfrom django_msms_admin.models import DjangoMsmsModelAbstractBase\n\nclass Book(DjangoMsmsModelAbstractBase, models.Model):\n title = models.CharField(max_length=64)\n author = models.CharField(max_length=64)\n\n def __str__(self):\n return self.title\n\nclass ComputerBook(Book):\n serial = models.CharField(max_length=64)\n\n cascade_select_description = \"These books are all about computers.\"\n cascade_select_image = static(\"app/img/computer-book.jpg\")\n\nclass NovelBook(Book):\n country = models.CharField(max_length=64)\n\n```\n\n**app/admin.py**\n\n```python\nfrom django.contrib import admin\nfrom django_msms_admin.admin import DjangoMsmsAdmin\nfrom django_msms_admin.admin import DjangoSubclassAdmin\n\nfrom .models import Book\nfrom .models import ComputerBook\nfrom .models import NovelBook\n\nclass BookAdmin(DjangoMsmsAdmin, admin.ModelAdmin):\n\n list_display = [\"title\", \"author\", \"type_name\"]\n list_filter = [\"type_name\"]\n\n\nadmin.site.register(Book, BookAdmin)\nadmin.site.register(ComputerBook, DjangoSubclassAdmin)\nadmin.site.register(NovelBook, DjangoSubclassAdmin)\n```\n\n## Release\n\n### v0.1.0 2020/03/03\n\n- First release.\n\n### v0.1.1 2020/03/05\n\n- Add DjangoMsmsModelAbstractBase.get_real_object method.\n\n### v0.1.2 2020/03/06\n\n- Fix keywords in setup.py and read requirements.txt for install_requires.\n\n### v0.2.0 2020/03/07\n\n- Use model's msms_category, msm_priority property to do model category and sorting.\n- Rename cascade_select_description to msms_description.\n- Rename cascade_select_preview_image to msms_image.\n\n### v0.2.1 2020/09/09\n\n- No depends on django-static-jquery3.\n- Using media.css & media.js to render css/js links.\n- Add LICENSE file.\n\n### v0.2.2 2023/09/18\n\n- Doc update.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Intelligent management for multiple subclass models in django's admin site.",
"version": "0.2.2",
"project_urls": null,
"split_keywords": [
"django admin extentions",
"django msms admin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a651c0858d2688ec016a7b28ac707efa11db011ba5234309766ecf4dd5ec8978",
"md5": "6dcf20478959a34f770f5b252eec2c7a",
"sha256": "96281ff8c4f5a34978e68056d076e98ef14673086f3c85bd50e6e66c585ad0f0"
},
"downloads": -1,
"filename": "django_msms_admin-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6dcf20478959a34f770f5b252eec2c7a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 10785,
"upload_time": "2023-09-18T01:58:12",
"upload_time_iso_8601": "2023-09-18T01:58:12.238263Z",
"url": "https://files.pythonhosted.org/packages/a6/51/c0858d2688ec016a7b28ac707efa11db011ba5234309766ecf4dd5ec8978/django_msms_admin-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "84f1f7ad84e8f7ec51eb051b0df05d84059c3dc6670bff4edd301dc45783a6b5",
"md5": "7c9c02263554fba9c68b7584e3db5c29",
"sha256": "9ed11ee1ffb7d5b5b64461a3b8df5fddb93333f93feef6ae038f4dc286d39048"
},
"downloads": -1,
"filename": "django-msms-admin-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "7c9c02263554fba9c68b7584e3db5c29",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9973,
"upload_time": "2023-09-18T01:58:14",
"upload_time_iso_8601": "2023-09-18T01:58:14.434787Z",
"url": "https://files.pythonhosted.org/packages/84/f1/f7ad84e8f7ec51eb051b0df05d84059c3dc6670bff4edd301dc45783a6b5/django-msms-admin-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-18 01:58:14",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-msms-admin"
}