Wizard implementation for Django admin
Project description
django-admin-wizard
django-admin-wizard is a Django app providing helpers for django admin actions with intermediate forms.
Description
Do you know "delete selected" action in Django-admin? This package provides helpers for creating such actions with intermediate forms in two lines of code. Also, you may add a link from django admin change page to a custom form view to perform some form-supplied action on single object.
Installation
pip install django-admin-wizard
Working example is in testproject.testapp
.
- Add application to installed apps in django settings:
INSTALLED_APPS.append('admin_wizard')
- And an action to your admin:
from django.contrib import admin from admin_wizard.admin import UpdateAction from testproject.testapp import forms, models @admin.register(models.MyModel) class MyModelAdmin(admin.ModelAdmin): actions = [UpdateAction(form_class=forms.RenameForm)]
- Add custom view to your admin:
from django.contrib import admin from django.urls import path from admin_wizard.admin import UpdateDialog from testproject.testapp import forms, models @admin.register(models.MyModel) class MyModelAdmin(admin.ModelAdmin): def get_urls(self): urls = [ path('<int:pk>/rename/', UpdateDialog.as_view(model_admin=self, model=models.MyModel, form_class=forms.RenameForm), name='rename') ] return urls + super().get_urls()
- Add a link to custom dialog in admin change page:
from django.contrib import admin from django.urls import reverse from testproject.testapp import models @admin.register(models.MyModel) class MyModelAdmin(admin.ModelAdmin): readonly_fields = ('update_obj_url',) def update_obj_url(self, obj): # FIXME: it's XSS, don't copy-paste url = reverse('admin:rename', kwargs=dict(pk=obj.pk)) return f'<a href="{url}">Rename...</a>' update_obj_url.short_description = 'rename'
Now you have "rename" action in changelist and "rename" link in change view. Enjoy :)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-admin-wizard-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d423f6373799e96bab5f4204077b05bd5efa468f29d28978162e2fcd0d0dbda3 |
|
MD5 | 4aec984a687f811dd6ea93b73db3c93b |
|
BLAKE2b-256 | 8f64e1d12fdd25199dd1e78fe627554250f9d26fef1677dd4e33c174d07c4fd2 |
Close
Hashes for django_admin_wizard-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2135b0e90bdf1a9790619a3062004db44b5ef754fb96b4998eecf2834f885d3 |
|
MD5 | 01a3c0fa6ab0f2a1775f28eb8c468582 |
|
BLAKE2b-256 | 186dcfb11ecf09394aee2f1c1a52aa3917f802c7830e7786a02c421db0148014 |