dashboard_getting_started.rst 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ===============
  2. Getting Started
  3. ===============
  4. .. note::
  5. Django JET Dashboard tries to be as compatible as possible with django-admin-tools dashboard so that
  6. django-admin-tools modules could be easily ported to Django JET. In most cases in will be enough to
  7. change python imports and remove extending in modules templates.
  8. Dashboard represents ``Dashboard`` class instance with ``DashboardModule`` class instances as its children.
  9. Any custom **Dashboard** class should inherit ``jet.dashboard.dashboard.Dashboard``
  10. and use ``init_with_context`` to fill it with widgets. You should add your widgets
  11. to ``children`` and ``available_children`` attributes.
  12. Set Up Custom Dashboard
  13. -----------------------
  14. * Create ``dashboard.py`` in any suitable location (e.g., in your project root) with the following content:
  15. .. code-block:: python
  16. from django.utils.translation import ugettext_lazy as _
  17. from jet.dashboard import modules
  18. from jet.dashboard.dashboard import Dashboard, AppIndexDashboard
  19. class CustomIndexDashboard(Dashboard):
  20. columns = 3
  21. def init_with_context(self, context):
  22. self.available_children.append(modules.LinkList)
  23. self.children.append(modules.LinkList(
  24. _('Support'),
  25. children=[
  26. {
  27. 'title': _('Django documentation'),
  28. 'url': 'http://docs.djangoproject.com/',
  29. 'external': True,
  30. },
  31. {
  32. 'title': _('Django "django-users" mailing list'),
  33. 'url': 'http://groups.google.com/group/django-users',
  34. 'external': True,
  35. },
  36. {
  37. 'title': _('Django irc channel'),
  38. 'url': 'irc://irc.freenode.net/django',
  39. 'external': True,
  40. },
  41. ],
  42. column=0,
  43. order=0
  44. ))
  45. * Add to your settings.py path to created ``dashboard.py`` (example for ``dashboard.py`` in project root):
  46. .. code:: python
  47. JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'
  48. That's all, now you have dashboard with only one widget - ``LinkList``. Dashboard reset may be needed
  49. if your had another dashboard already rendered for any user. Visit :doc:`dashboard_modules` to learn
  50. other widgets you can add to your custom dashboard or create your own.