• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    Python
  • Created over 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make bulk changes in the Django admin interface

Build Status Coverage Status

From Stanislaw Adaszewski's blog. I've fixed bugs and made changes to make it a production friendly drop-in Django app for bulk changes in Django's admin interface.

Check off what you want to edit in list view then choose mass edit from the actions menu. Image was taken using Grappelli

Alt text

Features

  • Drop in app, works with all models in admin
  • Doesn't allow users to edit unique and read only fields
  • Attempts to detect and show users errors
  • Database transactions ensure either all or no objects are changed

Not implemented

  • No support for inlines. Original had this. I commented it out because I felt it was very buggy.
  • Validation errors do not show up by the field they should

Installation

  1. pip install django-mass-edit
  2. In settings.py, add massadmin to INSTALLED_APPS
  3. Add path('admin/', include('massadmin.urls')), to urls.py before admin.site.urls line

Optional

You may exclude some fields like this:

```python
class PollAdmin(admin.ModelAdmin):
    massadmin_exclude = ['user', ]
```

You can also add or remove the "action" to models if you don't want it global. See Django Docs on the subject

Custom AdminSite

Django allows [customization of AdminSites](https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#customizing-adminsite)
If you want to work with a custom AdminSite by passing the custom site to the view (it is also necessary to add the `mass_change_selected` action to the custom site):

    ```python
    from massadmin import mass_change_selected

    admin_site = MyCustomAdminSite(name='custom_admin')
    admin_site.add_action(mass_change_selected)

    path('admin/', include(massadmin.urls), kwargs={'admin_site': admin_site}),
    ```

Settings

Enable Mass Edit for specific models

By default, all models registered in the admin will get Mass Edit action.

If you wish to disable this, add this to settings file:

MASSEDIT = {
    'ADD_ACTION_GLOBALLY': False,
}

Then, to add the mass edit action to specific models, use the provided mixin:

from massadmin.massadmin import MassEditMixin

class MyModelAdmin(MassEditMixin, admin.ModelAdmin):
    ...

Session-based URLs

Django-mass-edit will keep IDs for selected objects in URL, e.g:

/admin/myapp/mymodel-masschange/1,2,3,4,5/

To avoid problems with too long URL when editing large number of objects, the list of objects will be stored in session and the URL will look like this:

/admin/myapp/mymodel-masschange/session-c81e728d9d4c2f636f067f89cc14862c/

(same length regardless of the number of selected objects).

The default threshold is 500 characters for the IDs in the URL, not counting anything before or after the the IDs.

This threshold can be changed in settings:

MASSEDIT = {
    'SESSION_BASED_URL_THRESHOLD': 10,
}

To always use the session-based URLs, simply put in value 0.

Hacking and pull requests

This project could use some love. It has few unit test and old code that could be refactored. When you make a pull request - please include a unit test. If you want to take on improving the project let me know by opening an issue.

New maintainers welcome. I (bufke) will only be providing minimal support to keep the project running on modern versions of Django. Open an issue if you are interested.

More Repositories

1

django-report-builder

This is a github mirror for django-report-builder which is hosted on Gitlab. Django Report Builder is a GUI for Django ORM. Build custom queries and display results. Targets sys admins and capable end users who might not be able to program.
Python
750
star
2

schooldriver

A school information system made in django. Relies heavily on the django admin interface and includes many pluggable apps.
Python
185
star
3

django-simple-import

An import tool easy enough your users could use it
Python
138
star
4

django-responsive-dashboard

A generic and easy dashboard for Django applications.
Python
47
star
5

django-content-edit

A very simple way to let users edit content on the front end of a website when you don't quite need a full CMS.
HTML
24
star
6

GlitchTip

Mirror of https://gitlab.com/glitchtip/glitchtip
Dockerfile
12
star
7

django-admin-export

Generic export to xls action for Django admin interface
Python
11
star
8

django-report-utils

Common functions used for reporting needs. Used by django-report-builder and django-report-scaffold.
Python
10
star
9

django-auth-gapps

A simple way to authenticate to Google Apps using the provisioning API. If you want oath to allow any Google user to login look elsewhere. This is more like a Google Apps version of django-auth-ldap. It supports Group mappings as well.
Python
10
star
10

django-report-scaffold

Create streamlined and flexible reporting tools for your end users. Report scaffold is not a drop in application but a framework for creating reporting tools. Think of it like django admin.
Python
5
star
11

django-ldap-groups

A fork of django-ldap-groups
Python
3
star
12

BSC-website

Company website
Python
2
star
13

simple-asymmetric-python

github mirror - use https://gitlab.com/burke-software/simple-asymmetric-python
Python
2
star
14

handsontable-gradebook

An gradebook made with angular and handsontable.
JavaScript
1
star
15

django-floppy-gumby

Gumby Framework forms for Django using floppy forms. A floppy and gumby project.
Python
1
star