django的orm的内省接口。
django-admin2的Python项目详细描述
django.contrib.admin最有用的部分之一是 配置触摸和更改数据的各种视图。django-admin2是一个完整的 使用现代基于类的视图重写该库并享受设计 注重可扩展性和适应性。重新开始,我们可以避免 遗留代码,使编写扩展和主题更容易。
完整文档位于:https://django-admin2.readthedocs.io/
功能
- 重写django管理后端
- 下拉主题
- 内置restful api
要求
- Django 1.7+
- python 2.7+或python 3.3+
- django-braces
- django-extra-views
- django-rest-framework
- django-filter
- Sphinx(用于文档)
安装
使用pip从pypi安装:
pipinstalldjango-admin2
将djadmin2和rest_framework添加到您的设置文件中:
INSTALLED_APPS=(...'djadmin2','rest_framework',# for the browsable API templates...)
在设置文件中为应用程序和默认主题添加设置:
# In settings.pyINSTALLED_APPS+=('djadmin2.themes.djadmin2theme_bootstrap3',)REST_FRAMEWORK={'DEFAULT_PAGINATION_CLASS':'rest_framework.pagination.PageNumberPagination','PAGE_SIZE':10}ADMIN2_THEME_DIRECTORY="djadmin2theme_bootstrap3"
将djadmin2 url添加到urlconf:
# urls.pyfromdjango.conf.urlsimportincludefromdjadmin2.siteimportdjadmin2_sitedjadmin2_site.autodiscover()urlpatterns=[...url(r'^admin2/',include(djadmin2_site.urls)),]
如何编写django-admin2模块
# myapp/admin2.py# Import your custom modelsfromdjango.contrib.auth.formsimportUserCreationForm,UserChangeFormfromdjango.contrib.auth.modelsimportUserfromdjadmin2.siteimportdjadmin2_sitefromdjadmin2.typesimportModelAdmin2from.modelsimportPost,CommentclassUserAdmin2(ModelAdmin2):# Replicates the traditional admin for django.contrib.auth.models.Usercreate_form_class=UserCreationFormupdate_form_class=UserChangeForm# Register each model with the admindjadmin2_site.register(Post)djadmin2_site.register(Comment)djadmin2_site.register(User,UserAdmin2)
从0.6.x迁移
- 默认主题已更新为bootstrap3,请确保替换对新主题的引用。
- django rest框架还包括多个分页系统,目前唯一支持的是pagenumberpagination。
因此,您的设置需要包含以下内容:
# In settings.pyINSTALLED_APPS+=('djadmin2.themes.djadmin2theme_bootstrap3',)ADMIN2_THEME_DIRECTORY="djadmin2theme_bootstrap3"REST_FRAMEWORK={'DEFAULT_PAGINATION_CLASS':'rest_framework.pagination.PageNumberPagination','PAGE_SIZE':10}
默认的admin2站点已移动到djadmin2。请确保在URL中使用news djadmin2站点。py:
# urls.pyfromdjango.conf.urlsimportincludefromdjadmin2.siteimportdjadmin2_sitedjadmin2_site.autodiscover()urlpatterns=[...url(r'^admin2/',include(djadmin2_site.urls)),]
从0.5.x迁移
主题现在显式定义,包括默认主题。因此,您的设置需要包含以下内容:
# In settings.pyINSTALLED_APPS+=('djadmin2.themes.djadmin2theme_default',)ADMIN2_THEME_DIRECTORY="djadmin2theme_default"
下拉主题
默认主题是最新的引导程序。具体来说:
# In settings.pyINSTALLED_APPS+=('djadmin2.themes.djadmin2theme_bootstrap3',)ADMIN2_THEME_DIRECTORY="djadmin2theme_bootstrap3"
如果您创建了一个新主题,您可以这样定义它:
# In settings.py# Mythical theme! This does not exit... YET!INSTALLED_APPS+=('djadmin2theme_foundation',)ADMIN2_THEME_DIRECTORY="djadmin2theme_foundation"
行为准则
在django-admin2项目的代码库中进行交互的每个人,问题跟踪器,聊天 房间和邮件列表应遵循Jazzband Code of Conduct。
历史记录
0.7.0(2016-11-16)
- 修复django 1.8问题并添加1.9、1.10兼容性
- 将django rest framework更新为3.3.x
- 删除django crispy forms和django floppyforms
- 重新生成示例项目以使其与django 1.9兼容
- 更新tox和travis并添加flake8
- 将Admin Mule2MIIN改名为ADMI2MODEMIXIN
- 添加迁移
- 删除南迁
- 将ipaddressfield替换为genericpaddressfield
- 在用户管理中修复密码链接
- 在更改密码时修复用户注销问题
- 修复测试
- 放弃对低于1.8的django版本的支持
- 删除旧的url.patterns
0.6.1(2014-02-26)
- Fix empty form display
- Added more explicit installation instructions
- Added migration instructions
- Added view descriptions for “registry” and “app_verbose_names”
- Show a nice message and margin if there are no visible fields
- Updated widget controls for Django 1.6 changes.
- Better error messages for admin views that fail to instantiate
- Added png glyphicons to MANIFEST
0.6.0(2013-09-12)
- Implemented LogHistory to track recent history
- New system for adding new views to ModelAdmin2 object
- Fixed missing enctype=”multipart/form-data” functionality
- Implemented “app verbose name”
- Apps can have customized names
- List Actions can be set so they don’t require selecting a model
- Implemented ModelAdmin2.ordering
- To maintain API consistency, renamed views.AdminView’s “url” argument to “regex”
- Implemented ModelAdmin2.date_hierarchy
- Changed theming system to make default theme follow the same rules as third-party themes.
- Inlines now separated into stacked and tabular formats
- Code coverage now displaying in README
- User list page now showing all default columns and filters
- Vast documentation improvements
- Converted to ^{tt2}$ instead ^{tt3}$ in order to type edge cases
- setup.py fix
0.5.1(2013-07-14)
- No longer pinning dependencies on specific versions
- Documentation on built-in views shows context variables.
- Added django-filter to dependency list
- Problem with related_name resolved
- Fixed the height of the change_form
- Example app actually shows added content
- Pull requests going forward are internationalized
- FAQ begun
0.5.0(2013-07-08)
- Implemented customizable value renderers
- Implemented list filters using django-filters. Greatly supersedes what Django provides.
- Implemented ModelAdmin2.save_on_top and ModelAdmin2.save_on_bottom
- Implemented BooleanField icons for List and Detail views
- Implemented default ^{tt4}$ and ^{tt5}$ registrations
- Implemented the displayed of verbose field/method names in list view
- Implemented client-side ordering of model list fields in default theme
- Implemented improved internal naming conventions
- Improved example project home page
- Improved internal test coverage
- Documentation for Context Variables in Themes
- Corrected early nomenclature decisions
- Much improved Internationalization
- Added django-admin2 to Transifex
- Translations for French, Polish, Slovak, Chinese, German, Catalan, Italian, and Spanish.
0.4.0(2013-06-30)
- Implemented both Function- and Class-based Action views
- Implemented ModelAdmin2.list_display
- Implemented ModelAdmin2.fieldsets
- Dropdown widget now displays the selected choice
- Added support for callables in ModelAdmin2.list_display
- Added screenshots to README
- Added second example project
- Fixed breadcrumbs
- Default theme: Proper closing of template and media blocks
- Default theme: Standardized indentation in default theme templates
- Default theme: Pointed to CDN for JQuery
- Default theme: Added basic style for login form
- Default theme: Internationalized all text strings
0.3.0(2013-05-31)
- HTML5 forms via floppyforms.
- Many API improvements.
- Added Breadcrumbs.
- Added Login, Logout, ChangePassword views.
- Added Actions.
- Added support for inlines.
- Added view based permission controls
- Implement delete confirmations for child models.
- Testrunner now can run on a specific test set or module.
- Internal code refactoring to follow standards.
- Moved to git-flow for accepting pull requests.
- Model create/update pages now have save options.
- Added i18n to all templates, much of internal code.
- All print statements replaced with proper logging.
- Design goals specified in the documentation.
0.2.0(2013-05-19)
- Birth! (Working Prototype)
- Easy-to-extend API that follows similar patterns to django.contrib.admin.
- Built-in RESTFUL API powered by django-rest-framework.
- Default theme built on Twitter Bootstrap.
- Easy to implement theme system.
- Basic permission controls.
- Testrunner
- Documentation
0.1.1(2013-05-17)
- Code adoption from django-mongonaut.
- Preperation for Django Circus sprints.
0.1(2013-05-13)
- Discussion with Russell Keith-Magee.
- Inception.