django-admin2/README.rst

228 lines
6.4 KiB
ReStructuredText
Raw Normal View History

2015-12-13 20:37:03 +00:00
=============
2013-05-14 12:12:32 +00:00
django-admin2
2015-12-13 20:37:03 +00:00
=============
2013-05-14 12:12:32 +00:00
2016-06-24 12:48:15 +00:00
.. image:: https://jazzband.co/static/img/badge.svg
2016-06-08 18:26:19 +00:00
:target: https://jazzband.co/
:alt: Jazzband
.. image:: https://travis-ci.org/jazzband/django-admin2.png
:alt: Build Status
2016-06-08 18:26:19 +00:00
:target: https://travis-ci.org/jazzband/django-admin2
2016-06-24 12:50:52 +00:00
.. image:: https://coveralls.io/repos/github/jazzband/django-admin2/badge.svg?branch=develop
:alt: Coverage Status
2016-06-24 12:50:52 +00:00
:target: https://coveralls.io/github/jazzband/django-admin2?branch=develop
2014-11-10 02:45:54 +00:00
.. image:: https://badges.gitter.im/Join Chat.svg
:target: https://gitter.im/pydanny/django-admin2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
2013-07-06 14:33:59 +00:00
One of the most useful parts of ``django.contrib.admin`` is the ability to
configure various views that touch and alter data. django-admin2 is a complete
rewrite of that library using modern Class-Based Views and enjoying a design
focused on extendibility and adaptability. By starting over, we can avoid the
legacy code and make it easier to write extensions and themes.
Full Documentation at: https://django-admin2.readthedocs.io/
2013-05-18 06:44:31 +00:00
2013-07-05 14:48:46 +00:00
Features
2015-12-13 20:37:03 +00:00
========
2013-07-05 14:48:35 +00:00
* Rewrite of the Django Admin backend
* Drop-in themes
* Built-in RESTful API
Screenshots
===========
2016-06-08 18:26:19 +00:00
.. image:: https://github.com/jazzband/django-admin2/raw/develop/screenshots/Site_administration.png
:width: 722px
:alt: Site administration
:align: center
2016-06-08 18:26:19 +00:00
:target: https://github.com/jazzband/django-admin2/raw/develop/screenshots/Site_administration.png
2016-06-08 18:26:19 +00:00
.. image:: https://github.com/jazzband/django-admin2/raw/develop/screenshots/Select_user.png
:width: 722px
:alt: Select user
:align: center
2016-06-08 18:26:19 +00:00
:target: https://github.com/jazzband/django-admin2/raw/develop/screenshots/Select_user.png
2013-05-18 06:44:31 +00:00
2013-05-19 08:17:45 +00:00
Requirements
2015-12-13 20:37:03 +00:00
============
2013-05-19 08:17:45 +00:00
2018-09-03 05:11:14 +00:00
* Django 1.11+
* Python 2.7+ or Python 3.4+
2013-06-18 11:46:17 +00:00
* django-braces_
* django-extra-views_
* django-rest-framework_
2013-07-14 09:21:30 +00:00
* django-filter_
2013-06-18 11:46:17 +00:00
* Sphinx_ (for documentation)
.. _django-braces: https://github.com/brack3t/django-braces
.. _django-extra-views: https://github.com/AndrewIngram/django-extra-views
.. _django-rest-framework: https://github.com/tomchristie/django-rest-framework
2013-07-14 09:21:30 +00:00
.. _django-filter: https://github.com/alex/django-filter
2013-06-18 11:46:17 +00:00
.. _Sphinx: http://sphinx-doc.org/
2013-05-18 06:44:31 +00:00
2013-07-05 20:59:46 +00:00
Installation
============
2013-07-05 20:59:46 +00:00
Use pip to install from PyPI:
.. code-block:: python
pip install django-admin2
2013-07-06 00:06:07 +00:00
Add djadmin2 and rest_framework to your settings file:
2013-07-05 20:59:46 +00:00
.. code-block:: python
2013-07-07 14:45:12 +00:00
INSTALLED_APPS = (
...
'djadmin2',
'rest_framework', # for the browsable API templates
...
)
Add setting for apps and the default theme in your settings file:
.. code-block:: python
# In settings.py
INSTALLED_APPS += ('djadmin2.themes.djadmin2theme_bootstrap3',)
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
ADMIN2_THEME_DIRECTORY = "djadmin2theme_bootstrap3"
2013-07-05 20:59:46 +00:00
Add djadmin2 urls to your URLconf:
.. code-block:: python
# urls.py
from django.conf.urls import include
2013-07-06 13:18:01 +00:00
from djadmin2.site import djadmin2_site
2013-07-06 13:18:01 +00:00
djadmin2_site.autodiscover()
2013-07-05 20:59:46 +00:00
urlpatterns = [
2013-07-05 20:59:46 +00:00
...
2016-06-06 09:52:27 +00:00
url(r'^admin2/', include(djadmin2_site.urls)),
]
2013-07-05 20:59:46 +00:00
2013-07-05 14:53:04 +00:00
How to write django-admin2 modules
2015-12-13 20:37:03 +00:00
==================================
2013-05-14 12:12:32 +00:00
.. code-block:: python
2013-05-14 12:12:32 +00:00
# myapp/admin2.py
# Import your custom models
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.models import User
2016-06-06 09:52:27 +00:00
from djadmin2.site import djadmin2_site
from djadmin2.types import ModelAdmin2
2013-05-14 12:12:32 +00:00
2013-06-30 09:38:39 +00:00
from .models import Post, Comment
2013-05-14 12:12:32 +00:00
2016-06-06 09:52:27 +00:00
class UserAdmin2(ModelAdmin2):
2013-07-05 14:48:35 +00:00
# Replicates the traditional admin for django.contrib.auth.models.User
create_form_class = UserCreationForm
update_form_class = UserChangeForm
# Register each model with the admin
2016-06-06 09:52:27 +00:00
djadmin2_site.register(Post)
djadmin2_site.register(Comment)
djadmin2_site.register(User, UserAdmin2)
2013-05-17 10:38:39 +00:00
Migrating from 0.6.x
2013-09-18 09:53:32 +00:00
====================
- The default theme has been updated to bootstrap3, be sure to replace your reference to the new one.
- Django rest framework also include multiple pagination system, the only one supported now is the PageNumberPagination.
Therefore, your `settings` need to include this:
2013-09-18 09:53:32 +00:00
.. code-block:: python
# In settings.py
INSTALLED_APPS += ('djadmin2.themes.djadmin2theme_bootstrap3',)
ADMIN2_THEME_DIRECTORY = "djadmin2theme_bootstrap3"
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
2013-09-18 09:53:32 +00:00
The default admin2 site has move into djadmin2.site make sure your use the news djadmin2_site in your urls.py:
.. code-block:: python
# urls.py
from django.conf.urls import include
from djadmin2.site import djadmin2_site
djadmin2_site.autodiscover()
urlpatterns = [
...
2016-06-06 09:52:27 +00:00
url(r'^admin2/', include(djadmin2_site.urls)),
]
Migrating from 0.5.x
====================
Themes are now defined explicitly, including the default theme. Therefore, your `settings` need to include this:
.. code-block:: python
# In settings.py
INSTALLED_APPS += ('djadmin2.themes.djadmin2theme_default',)
ADMIN2_THEME_DIRECTORY = "djadmin2theme_default"
2013-07-05 14:48:35 +00:00
Drop-In Themes
2015-12-13 20:37:03 +00:00
==============
The default theme is whatever bootstrap is most current. Specifically:
.. code-block:: python
2013-08-01 10:46:38 +00:00
# In settings.py
INSTALLED_APPS += ('djadmin2.themes.djadmin2theme_bootstrap3',)
ADMIN2_THEME_DIRECTORY = "djadmin2theme_bootstrap3"
2013-07-05 14:53:04 +00:00
If you create a new theme, you define it thus:
.. code-block:: python
2013-08-01 10:46:38 +00:00
# In settings.py
# Mythical theme! This does not exit... YET!
INSTALLED_APPS += ('djadmin2theme_foundation',)
ADMIN2_THEME_DIRECTORY = "djadmin2theme_foundation"
2016-06-08 18:26:19 +00:00
Code of Conduct
======================
Everyone interacting in the django-admin2 project's codebases, issue trackers, chat
2016-06-08 18:26:19 +00:00
rooms, and mailing lists is expected to follow the `Jazzband Code of Conduct`_.
.. _`Jazzband Code of Conduct`: https://jazzband.co/about/conduct
2014-03-05 01:59:55 +00:00
Follows Best Practices
======================
.. image:: http://twoscoops.smugmug.com/Two-Scoops-Press-Media-Kit/i-C8s5jkn/0/O/favicon-152.png
:name: Two Scoops Logo
:align: center
:alt: Two Scoops of Django
2015-12-13 20:35:18 +00:00
:target: http://twoscoopspress.org/products/two-scoops-of-django-1-8
2014-03-05 01:59:55 +00:00
2015-12-13 20:35:18 +00:00
This project follows best practices as espoused in `Two Scoops of Django: Best Practices for Django 1.8`_.
2014-03-05 01:59:55 +00:00
2015-12-13 20:35:18 +00:00
.. _`Two Scoops of Django: Best Practices for Django 1.8`: http://twoscoopspress.org/products/two-scoops-of-django-1-8