Skip to main content

Extensions for django-xadmin

Project description

Extra features for django-xadmin

New features:

Form wizard

Integrate Django FormWizards with xadmin views:

Any view using a wizard should inherit from FormWizardAdminView

from xadmin_extras.wizard import FormWizardAdminView, SessionWizardViewMixin

class NotificateView(SessionWizardViewMixin, FormWizardAdminView):
    """A wizard view working together with xadmin, using
    SessionWizard backend

    """
    form_list = [SelectFilterForm, NotificateForm]
    form_template = 'admin/fbapps/notificate_form.html'
    title = 'FB Push notifications'

Other wizard backends are available: SessionWizardViewMixin and CookieWizardViewMixin

For more info about Form wizard, see django documentation

To register a view to be available at admin, with name and protected, use register_view():

import xadmin
xadmin.site.register_view(
    r'fbapps/notificate/$', NotificateView,
    name='fbapps_notification_view')

Custom menu entries

Using an AppConfig-like class (available for Django 1.7), custom entries can be added for the menu of each App.

Create a file called apps.py at your app folder, create a class and edit init_menu()

# coding=utf-8

# from django.apps import AppConfig (commented for django 1.6)
from xadmin_extras.apps import AdminAppMixin


class FooConfig(AdminAppMixin):
    """name and verbose_name are going to be used for django AppConfig too

    """
    name = 'foo'
    verbose_name = 'Foo app.'
    icon = 'foo'

    def init_menu(self):
        """Add custom menu entries to the menu displayed for this app

        Return a list of dicts, each dict will be a entry for the submenu of
        the app:
            {'url': '/admin/.../', 'icon': 'bolt', 'title': 'Custom'}
        also 'perm' and 'order' keys can be added.

        """
        return [{
            'url': '/admin/foo/notification/', 'icon': 'bolt',
            'title': u'Send notifications', 'order': '', 'perm': None}]


APP_CONFIG = FooConfig()

Now, assign the app to each model you want to get grouped and register them

import xadmin
import .models as models

class AppAdmin(object):
    app_config = AppConfig

xadmin.site.register(models.Foo, AppAdmin)

After that, you just need to extend CommAdminView (maybe you have already done this if you wanted to change menu style, site title, base template, etc.), with AppConfigViewMixin available at xadmin_extras.views

import xadmin.views as views
import xadmin_extras as views_extra

xadmin.site.register(views.CommAdminView, views_extra.AppConfigViewMixin)

django-hstore support

Add the widget XadminHStoreWidget to your form definition:

from django_hstore.forms import DictionaryField
from xadmin_extras.django_hstore.widgets import XAdminHStoreWidget
from django import forms


class HStoreForm(forms.Form):
        data = DictionaryField(widget=XadminHStoreWidget())

External apps support

Apps with custom views are defined at ext folder

django-celery

import xadmin_extras.ext.celery as ext_celery

xadmin.site.register(
        ext_celery.celery_models.PeriodicTask, ext_celery.PeriodicTaskAdmin)
xadmin.site.register(
        ext_celery.celery_models.IntervalSchedule,
        ext_celery.IntervalScheduleAdmin)
xadmin.site.register(
        ext_celery.celery_models.CrontabSchedule,
        ext_celery.CrontabScheduleAdmin)

django-settings

import xadmin_extras.ext.settings as ext_settings

xadmin.site.register(ext_settings.models.Setting, ext_settings.SettingsAdmin)

django-mail-factory

(By default, the mails will be at URL: /admin/mails/)

from xadmin.views import CommAdminView, filter_hook, FormAdminView

import xadmin_extras.ext.mailfactory as ext_mailfactory

xadmin.site.register_view(
        r'^mails/$', ext_mailfactory.MailListView, name='mail_factory_list')
xadmin.site.register_view(
        r'^mails/(?P<mail_name>.*)/$',ext_mailfactory.MailFormView, name='mail_factory_form')
xadmin.site.register_view(
        r'^mails/(?P<mail_name>.*)/preview/(?P<lang>\w+)/$',
        ext_mailfactory.MailPreviewMessageView, name='mail_factory_preview_message')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-xadmin-extras-0.14.tar.gz (17.1 kB view details)

Uploaded Source

File details

Details for the file django-xadmin-extras-0.14.tar.gz.

File metadata

File hashes

Hashes for django-xadmin-extras-0.14.tar.gz
Algorithm Hash digest
SHA256 b5c661eb27ff48f96a18293d7aa1ce05e6cade9a7f2518f08d260683330bca3f
MD5 866e541425ad2d82700b787649a56ad8
BLAKE2b-256 8e74067df7ff8e3e5a890dc1958951857c08998544ecc842bbdc64c137d14139

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page