Code Monkey home page Code Monkey logo

django-mass-edit's People

Contributors

andreynovikov avatar bourivouh avatar bufke avatar cript0nauta avatar cuchac avatar d33tah avatar danialmalik avatar ecederstrand avatar elfgzp avatar empty avatar francescortiz avatar frnhr avatar kennknowles avatar ludwiktrammer avatar mondaini avatar pacotole avatar pedrovhb avatar petrdlouhy avatar poligarcia avatar pombredanne avatar rblack avatar shanx avatar syrusakbary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-mass-edit's Issues

Incompatibility with custom AdminSite overriding each_context

We are using a custom AdminSite, where the each_context() is overridden to add some additional context variables. Our base_site.html template then uses these variables. This causes an error when rendering the mass change view, because it doesn't include the context variables from the each_context() function.

Here's an example showing how Django's default admin views use each_context(): https://github.com/django/django/blob/2.2.11/django/contrib/admin/options.py#L1616

I will post a PR with a fix for this soon.

Handling long drop-down lists

dme is a very useful tool, but as our database has grown, so has the length of many of the drop-down lists & we have had to disable some to allow for reasonable page load times. Could there be some consideration given to allow dme to support django-selectable (http://django-selectable.readthedocs.org/en/latest/index.html) which allow for incremental lookups and thereby avoids the problems of loading large lists at page creation time? Thanks!

Suggestion: check 'unique together' after form submission

mass-edit correctly excludes unique fields from the form before it even gets created. What would be very helpful to prevent potential problems is to add a check to the form after its filled in (but before the change process is run) so that the 'unique_together' property in the model Meta is also validated.

For example, I have a Location type of model. Neither its 'name' or 'region' are individually unique, but the combination has to be. The mass-edit form should throw an error if a user tries to fill in both of those fields at the same time.

Django 1.10.2 working?

I have installed master and updated urls but I am not getting the mass edit form only a single form for the first object. Did a quick bit of debugging and everything seems to be reaching mass_change_view correctly. Any ideas?

RemovedInDjango19Warning

[root@e85a0fc40662 /]# /usr/lib64/python2.7/site-packages/django/contrib/admin/util.py:7: RemovedInDjango19Warning: The django.contrib.admin.util module has been renamed. Use django.contrib.admin.utils instead.
  "Use django.contrib.admin.utils instead.", RemovedInDjango19Warning)

Looks like massadmin.py references this.

Django 1.10 compatibility

There is warning about future incompatibility with Django 1.10

/env/lib/python3.4/site-packages/massadmin/urls.py:7: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.

Add set password support

In some cases users would like to set passwords to be the same in mass.

Right now one can only set the password hash which end users don't understand.

Catching an error?

I am getting this error:

File "/usr/local/lib/python2.7/dist-packages/massadmin/massadmin.py" in mass_change_view
  193.                         raise Exception('Some of the selected objects could\'t be changed.')

There is nothing in the stack trace to indicate what is causing it or what records are not changed.

How I do catch this exception and report to the user which records could not be changed (and why)?

Mass edit error

Trying to make changes to boolean fields on a model; how I can debug/fix this:

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/decorators.py" in _checklogin
  16.             return view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_mass_edit-1.4-py2.7.egg/massadmin/massadmin.py" in mass_change_view
  65.     return ma.mass_change_view(request, object_ids)
File "/usr/local/lib/python2.7/dist-packages/django_mass_edit-1.4-py2.7.egg/massadmin/massadmin.py" in mass_change_view
  193.                         raise Exception('Some of the selected objects could\'t be changed.')

Exception Type: Exception at /admin/foos/foo-masschange/2935,2937/
Exception Value: Some of the selected objects could't be changed.

Licensing?

There isn't a license file for this project. The original was BSD so I would assume this is an extension. If you can confirm that would be great!

Exception Value: 'Options' object has no attribute 'module_name'

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/core/member/

Django Version: 1.8.2
Python Version: 3.4.0
Installed Applications:
('massadmin',
'bootstrap3',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/contrib/admin/options.py" in wrapper
  2.             return self.admin_site.admin_view(view)(_args, *_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/utils/decorators.py" in _wrapped_view
  3.                 response = view_func(request, _args, *_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  4.     response = view_func(request, _args, *_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/contrib/admin/sites.py" in inner
  5.         return view(request, _args, *_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/utils/decorators.py" in _wrapper
  6.         return bound_func(_args, *_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/utils/decorators.py" in _wrapped_view
  7.                 response = view_func(request, _args, *_kwargs)
    
    File "/usr/local/lib/python3.4/dist-packages/django/utils/decorators.py" in bound_func
  8.             return func.**get**(self, type(self))(_args2, *_kwargs2)
    
    File "/usr/local/lib/python3.4/dist-packages/django/contrib/admin/options.py" in changelist_view
  9.             response = self.response_action(request, queryset=cl.get_queryset(request))
    
    File "/usr/local/lib/python3.4/dist-packages/django/contrib/admin/options.py" in response_action
  10.         response = func(self, request, queryset)
    
    File "/usr/local/lib/python3.4/dist-packages/massadmin/massadmin.py" in mass_change_selected
  11.     (modeladmin.model._meta.module_name, ','.join(selected)))
    

Exception Type: AttributeError at /admin/core/member/
Exception Value: 'Options' object has no attribute 'module_name'

500 error when related field present.

Not sure why this particular case fails.

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  1.                     response = callback(request, _callback_args, *_callback_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/decorators.py" in _checklogin
  2.         return view_func(request, _args, *_kwargs)
    
    File "/home/david/Dropbox/Projects/django-mass-edit/massadmin/massadmin.py" in mass_change_view
  3. return ma.mass_change_view(request, object_ids)
    
    File "/home/david/Dropbox/Projects/django-mass-edit/massadmin/massadmin.py" in mass_change_view
  4.     ModelForm = self.get_form(request, obj)
    
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in get_form
  5.     return modelform_factory(self.model, **defaults)
    
    File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in modelform_factory
  6. return type(form)(class_name, (form,), form_class_attrs)
    
    File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in new
  7.             raise FieldError(message)
    

Exception Type: FieldError at /admin/alumni/alumni-masschange/1036,1035/
Exception Value: Unknown field(s) (alumniaction_set) specified for Alumni

No integration with custom admin site

I'm on Python 3 with Django 1.8 and noticed that I can see mass-edits admin action in the drop down of change lists only if I use Django's default admin site. When I start using a custom admin site, it is no longer there and I can't mass-edit any model.

Uncaught error when edit creates duplicate entries

If a user makes a changes that results in mass-edit creating one or more records that have duplicate entries, then an error is thrown that is not handled.

Is it possible that mass-edit can catch these and rather return a set of messages/warnings as to why the records in question were not altered?

File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/views/decorators.py" in _checklogin
  17.             return view_func(request, *args, **kwargs)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/massadmin/massadmin.py" in mass_change_view
  65.     return ma.mass_change_view(request, object_ids)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/massadmin/massadmin.py" in mass_change_view
  183.                             self.save_model(request, new_object, form, change=True)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_model
  740.         obj.save()
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py" in save
  546.                        force_update=force_update, update_fields=update_fields)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base
  626.                             rows = manager.using(using).filter(pk=pk_val)._update(values)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/query.py" in _update
  605.         return query.get_compiler(self.db).execute_sql(None)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1020.         cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  846.         cursor.execute(sql, params)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  41.             return self.cursor.execute(sql, params)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
  122.             six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
  120.             return self.cursor.execute(query, args)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute
  201.             self.errorhandler(self, exc, value)
File "/home/creation/.virtualenvs/s2s/local/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler
  36.     raise errorclass, errorvalue

Exception Type: IntegrityError at /admin/myapp/site-masschange/120,121,124,122,123,365,371,377,383,389/
Exception Value: (1062, "Duplicate entry '5-1-1' for key 'site_id_2'")

Update PyPI package

Please update PyPI package with version that is compatible with Django 2.0.

Error mass-editing multiple records with custom primary keys

I'm slightly new to Django so I'm not sure if this is my fault, but these models have been working fine. I get an error when I try to mass update them though.

NoReverseMatch at /admin/inventory/product/
Reverse for 'massadmin_change_view' with arguments '()' and keyword arguments '{'model_name': 'product', 'app_name': 'inventory', 'object_ids': 'MBX-99-888,SIZ-66-6666'}' not found. 1 pattern(s) tried: ['admin/(?P<app_name>[^/]+)/(?P<model_name>[^/]+)-masschange/(?P<object_ids>[\\w,\\.]+)/$']
Request Method:	POST
Request URL:	http://192.168.0.15:8005/admin/inventory/product/
Django Version:	1.10
Exception Type:	NoReverseMatch
Exception Value:	
Reverse for 'massadmin_change_view' with arguments '()' and keyword arguments '{'model_name': 'product', 'app_name': 'inventory', 'object_ids': 'MBX-99-888,SIZ-66-6666'}' not found. 1 pattern(s) tried: ['admin/(?P<app_name>[^/]+)/(?P<model_name>[^/]+)-masschange/(?P<object_ids>[\\w,\\.]+)/$']
Exception Location:	/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/urls/resolvers.py in _reverse_with_prefix, line 389
Python Executable:	/usr/bin/uwsgi
Python Version:	3.4.5
Python Path:	
['.',
 '',
 '/home/ryan/apps/kingsway/venv/lib/python34.zip',
 '/home/ryan/apps/kingsway/venv/lib64/python3.4',
 '/home/ryan/apps/kingsway/venv/lib64/python3.4/plat-linux',
 '/home/ryan/apps/kingsway/venv/lib64/python3.4/lib-dynload',
 '/usr/lib64/python3.4',
 '/usr/lib/python3.4',
 '/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages']
Server time:	Fri, 6 Jan 2017 15:21:16 -0800
Traceback Switch to copy-and-paste view

/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/core/handlers/exception.py in inner
            response = get_response(request) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/core/handlers/base.py in _legacy_get_response
            response = self._get_response(request) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/core/handlers/base.py in _get_response
                response = self.process_exception_by_middleware(e, request) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/core/handlers/base.py in _get_response
                response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/contrib/admin/options.py in wrapper
                return self.admin_site.admin_view(view)(*args, **kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/utils/decorators.py in _wrapped_view
                    response = view_func(request, *args, **kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/views/decorators/cache.py in _wrapped_view_func
        response = view_func(request, *args, **kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/contrib/admin/sites.py in inner
            return view(request, *args, **kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/utils/decorators.py in _wrapper
            return bound_func(*args, **kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/utils/decorators.py in _wrapped_view
                    response = view_func(request, *args, **kwargs) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/utils/decorators.py in bound_func
                return func.__get__(self, type(self))(*args2, **kwargs2) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/contrib/admin/options.py in changelist_view
                response = self.response_action(request, queryset=cl.get_queryset(request)) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/contrib/admin/options.py in response_action
            response = func(self, request, queryset) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/massadmin/massadmin.py in mass_change_selected
                "object_ids": ",".join(str(s) for s in selected)}) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/urls/base.py in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))) ...
ā–¶ Local vars
/home/ryan/apps/kingsway/venv/lib/python3.4/site-packages/django/urls/resolvers.py in _reverse_with_prefix
            (lookup_view_s, args, kwargs, len(patterns), patterns) ...
ā–¶ Local vars
Request information

USER
ryan
GET
No GET data
POST
Variable	Value
select_across	
'0'
index	
'0'
csrfmiddlewaretoken	
'OvtfWkdznQIO5bWo5C9icnFO1WcSRQGl7rcNK3inwFGDF4SJgYyKnUJUjoIc2s9Z'
_selected_action	
'SIZ-66-6666'
action	
'mass_change_selected'
FILES
No FILES data
COOKIES
Variable	Value
tabstyle	
'html-tab'
sessionid	
'zkrv0xhrewftu459e3i7tc0sdh9tnpnu'
gsScrollPos	
''
csrftoken	
'yzRMhyze1nq2XxQ6uXYHagmYb6q3M3htRvAk5hE2acoRxqMrFjn9lNq4tyWnXFK7'
META
Variable	Value
CONTENT_LENGTH	
'193'
CONTENT_TYPE	
'application/x-www-form-urlencoded'
CSRF_COOKIE	
'yzRMhyze1nq2XxQ6uXYHagmYb6q3M3htRvAk5hE2acoRxqMrFjn9lNq4tyWnXFK7'
DOCUMENT_ROOT	
'/usr//html'
HTTP_ACCEPT	
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
HTTP_ACCEPT_ENCODING	
'gzip, deflate'
HTTP_ACCEPT_LANGUAGE	
'en-US,en;q=0.8,it;q=0.6'
HTTP_CACHE_CONTROL	
'max-age=0'
HTTP_CONNECTION	
'keep-alive'
HTTP_CONTENT_LENGTH	
'193'
HTTP_CONTENT_TYPE	
'application/x-www-form-urlencoded'
HTTP_COOKIE	
('gsScrollPos=; sessionid=zkrv0xhrewftu459e3i7tc0sdh9tnpnu; '
 'tabstyle=html-tab; '
 'csrftoken=yzRMhyze1nq2XxQ6uXYHagmYb6q3M3htRvAk5hE2acoRxqMrFjn9lNq4tyWnXFK7')
HTTP_HOST	
'192.168.0.15:8005'
HTTP_ORIGIN	
'http://192.168.0.15:8005'
HTTP_REFERER	
'http://192.168.0.15:8005/admin/inventory/product/'
HTTP_UPGRADE_INSECURE_REQUESTS	
'1'
HTTP_USER_AGENT	
('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like '
 'Gecko) Chrome/55.0.2883.87 Safari/537.36')
PATH_INFO	
'/admin/inventory/product/'
QUERY_STRING	
''
REMOTE_ADDR	
'192.168.0.2'
REMOTE_PORT	
'63802'
REQUEST_METHOD	
'POST'
REQUEST_URI	
'/admin/inventory/product/'
SCRIPT_NAME	
''
SERVER_NAME	
'kingsway.treasuremart.net'
SERVER_PORT	
'8005'
SERVER_PROTOCOL	
'HTTP/1.1'
uwsgi.core	
33
uwsgi.node	
b'ls4'
uwsgi.version	
b'2.0.13.1'
wsgi.errors	
<_io.TextIOWrapper name=2 mode='w' encoding='ANSI_X3.4-1968'>
wsgi.file_wrapper	
''
wsgi.input	
<uwsgi._Input object at 0x7fa52fbcb918>
wsgi.multiprocess	
False
wsgi.multithread	
True
wsgi.run_once	
False
wsgi.url_scheme	
'http'
wsgi.version	
(1, 0)
Settings
Using settings module mysite.settings
Setting	Value
ABSOLUTE_URL_OVERRIDES	
{}
ACCOUNT_ACTIVATION_DAYS	
90
ADMINS	
[]
ALLOWED_HOSTS	
[]
APPEND_SLASH	
True
AUTHENTICATION_BACKENDS	
['django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS	
'********************'
AUTH_USER_MODEL	
'auth.User'
BASE_DIR	
'/home/ryan/apps/kingsway/content'
CACHES	
{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS	
'default'
CACHE_MIDDLEWARE_KEY_PREFIX	
'********************'
CACHE_MIDDLEWARE_SECONDS	
600
CSRF_COOKIE_AGE	
31449600
CSRF_COOKIE_DOMAIN	
None
CSRF_COOKIE_HTTPONLY	
False
CSRF_COOKIE_NAME	
'csrftoken'
CSRF_COOKIE_PATH	
'/'
CSRF_COOKIE_SECURE	
False
CSRF_FAILURE_VIEW	
'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME	
'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS	
[]
DATABASES	
{'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 0,
             'ENGINE': 'django.db.backends.postgresql_psycopg2',
             'HOST': 'localhost',
             'NAME': 'kingsway',
             'OPTIONS': {},
             'PASSWORD': '********************',
             'PORT': '5432',
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': None,
             'USER': 'ryan'}}
DATABASE_ROUTERS	
[]
DATA_UPLOAD_MAX_MEMORY_SIZE	
2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS	
1000
DATETIME_FORMAT	
'N j, Y, P'
DATETIME_INPUT_FORMATS	
['%Y-%m-%d %H:%M:%S',
 '%Y-%m-%d %H:%M:%S.%f',
 '%Y-%m-%d %H:%M',
 '%Y-%m-%d',
 '%m/%d/%Y %H:%M:%S',
 '%m/%d/%Y %H:%M:%S.%f',
 '%m/%d/%Y %H:%M',
 '%m/%d/%Y',
 '%m/%d/%y %H:%M:%S',
 '%m/%d/%y %H:%M:%S.%f',
 '%m/%d/%y %H:%M',
 '%m/%d/%y']
DATE_FORMAT	
'N j, Y'
DATE_INPUT_FORMATS	
['%Y-%m-%d',
 '%m/%d/%Y',
 '%m/%d/%y',
 '%b %d %Y',
 '%b %d, %Y',
 '%d %b %Y',
 '%d %b, %Y',
 '%B %d %Y',
 '%B %d, %Y',
 '%d %B %Y',
 '%d %B, %Y']
DEBUG	
True
DEBUG_PROPAGATE_EXCEPTIONS	
False
DECIMAL_SEPARATOR	
'.'
DEFAULT_CHARSET	
'utf-8'
DEFAULT_CONTENT_TYPE	
'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER	
'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE	
'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL	
'[email protected]'
DEFAULT_INDEX_TABLESPACE	
''
DEFAULT_TABLESPACE	
''
DISALLOWED_USER_AGENTS	
[]
EMAIL_BACKEND	
'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST	
'localhost'
EMAIL_HOST_PASSWORD	
'********************'
EMAIL_HOST_USER	
''
EMAIL_PORT	
25
EMAIL_SSL_CERTFILE	
None
EMAIL_SSL_KEYFILE	
'********************'
EMAIL_SUBJECT_PREFIX	
'[Django] '
EMAIL_TIMEOUT	
None
EMAIL_USE_SSL	
False
EMAIL_USE_TLS	
False
FILE_CHARSET	
'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS	
None
FILE_UPLOAD_HANDLERS	
['django.core.files.uploadhandler.MemoryFileUploadHandler',
 'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE	
2621440
FILE_UPLOAD_PERMISSIONS	
None
FILE_UPLOAD_TEMP_DIR	
None
FIRST_DAY_OF_WEEK	
0
FIXTURE_DIRS	
[]
FORCE_SCRIPT_NAME	
None
FORMAT_MODULE_PATH	
None
IGNORABLE_404_URLS	
[]
INSTALLED_APPS	
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'registration',
 'registration.supplements.default',
 'base_registration',
 'inventory',
 'purchase_orders',
 'invoicing',
 'rest_framework',
 'rest_framework.authtoken',
 'massadmin')
INTERNAL_IPS	
[]
LANGUAGES	
[('af', 'Afrikaans'),
 ('ar', 'Arabic'),
 ('ast', 'Asturian'),
 ('az', 'Azerbaijani'),
 ('bg', 'Bulgarian'),
 ('be', 'Belarusian'),
 ('bn', 'Bengali'),
 ('br', 'Breton'),
 ('bs', 'Bosnian'),
 ('ca', 'Catalan'),
 ('cs', 'Czech'),
 ('cy', 'Welsh'),
 ('da', 'Danish'),
 ('de', 'German'),
 ('dsb', 'Lower Sorbian'),
 ('el', 'Greek'),
 ('en', 'English'),
 ('en-au', 'Australian English'),
 ('en-gb', 'British English'),
 ('eo', 'Esperanto'),
 ('es', 'Spanish'),
 ('es-ar', 'Argentinian Spanish'),
 ('es-co', 'Colombian Spanish'),
 ('es-mx', 'Mexican Spanish'),
 ('es-ni', 'Nicaraguan Spanish'),
 ('es-ve', 'Venezuelan Spanish'),
 ('et', 'Estonian'),
 ('eu', 'Basque'),
 ('fa', 'Persian'),
 ('fi', 'Finnish'),
 ('fr', 'French'),
 ('fy', 'Frisian'),
 ('ga', 'Irish'),
 ('gd', 'Scottish Gaelic'),
 ('gl', 'Galician'),
 ('he', 'Hebrew'),
 ('hi', 'Hindi'),
 ('hr', 'Croatian'),
 ('hsb', 'Upper Sorbian'),
 ('hu', 'Hungarian'),
 ('ia', 'Interlingua'),
 ('id', 'Indonesian'),
 ('io', 'Ido'),
 ('is', 'Icelandic'),
 ('it', 'Italian'),
 ('ja', 'Japanese'),
 ('ka', 'Georgian'),
 ('kk', 'Kazakh'),
 ('km', 'Khmer'),
 ('kn', 'Kannada'),
 ('ko', 'Korean'),
 ('lb', 'Luxembourgish'),
 ('lt', 'Lithuanian'),
 ('lv', 'Latvian'),
 ('mk', 'Macedonian'),
 ('ml', 'Malayalam'),
 ('mn', 'Mongolian'),
 ('mr', 'Marathi'),
 ('my', 'Burmese'),
 ('nb', 'Norwegian BokmƄl'),
 ('ne', 'Nepali'),
 ('nl', 'Dutch'),
 ('nn', 'Norwegian Nynorsk'),
 ('os', 'Ossetic'),
 ('pa', 'Punjabi'),
 ('pl', 'Polish'),
 ('pt', 'Portuguese'),
 ('pt-br', 'Brazilian Portuguese'),
 ('ro', 'Romanian'),
 ('ru', 'Russian'),
 ('sk', 'Slovak'),
 ('sl', 'Slovenian'),
 ('sq', 'Albanian'),
 ('sr', 'Serbian'),
 ('sr-latn', 'Serbian Latin'),
 ('sv', 'Swedish'),
 ('sw', 'Swahili'),
 ('ta', 'Tamil'),
 ('te', 'Telugu'),
 ('th', 'Thai'),
 ('tr', 'Turkish'),
 ('tt', 'Tatar'),
 ('udm', 'Udmurt'),
 ('uk', 'Ukrainian'),
 ('ur', 'Urdu'),
 ('vi', 'Vietnamese'),
 ('zh-hans', 'Simplified Chinese'),
 ('zh-hant', 'Traditional Chinese')]
LANGUAGES_BIDI	
['he', 'ar', 'fa', 'ur']
LANGUAGE_CODE	
'en-us'
LANGUAGE_COOKIE_AGE	
None
LANGUAGE_COOKIE_DOMAIN	
None
LANGUAGE_COOKIE_NAME	
'django_language'
LANGUAGE_COOKIE_PATH	
'/'
LOCALE_PATHS	
[]
LOGGING	
{}
LOGGING_CONFIG	
'logging.config.dictConfig'
LOGIN_REDIRECT_URL	
'/accounts/profile/'
LOGIN_URL	
'/accounts/login/'
LOGOUT_REDIRECT_URL	
None
MANAGERS	
[]
MEDIA_ROOT	
''
MEDIA_URL	
''
MESSAGE_STORAGE	
'django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE	
None
MIDDLEWARE_CLASSES	
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')
MIGRATION_MODULES	
{}
MONTH_DAY_FORMAT	
'F j'
NUMBER_GROUPING	
0
PASSWORD_HASHERS	
'********************'
PASSWORD_RESET_TIMEOUT_DAYS	
'********************'
PREPEND_WWW	
False
REGISTRATION_ACCEPTANCE_EMAIL	
True
REGISTRATION_ACTIVATION_EMAIL	
True
REGISTRATION_BACKEND_CLASS	
'registration.backends.default.DefaultRegistrationBackend'
REGISTRATION_DEFAULT_PASSWORD_LENGTH	
'********************'
REGISTRATION_DJANGO_AUTH_URLS_ENABLE	
True
REGISTRATION_DJANGO_AUTH_URL_NAMES_PREFIX	
''
REGISTRATION_DJANGO_AUTH_URL_NAMES_SUFFIX	
''
REGISTRATION_OPEN	
True
REGISTRATION_REGISTRATION_EMAIL	
True
REGISTRATION_REJECTION_EMAIL	
True
REGISTRATION_SUPPLEMENT_ADMIN_INLINE_BASE_CLASS	
'registration.admin.RegistrationSupplementAdminInlineBase'
REGISTRATION_SUPPLEMENT_CLASS	
'base_registration.models.MyRegistrationSupplement'
REGISTRATION_USE_OBJECT_PERMISSION	
False
REST_FRAMEWORK	
{'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.TokenAuthentication',
                                    'rest_framework.authentication.SessionAuthentication'),
 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',
                                'rest_framework.permissions.IsAdminUser')}
ROOT_URLCONF	
'mysite.urls'
SECRET_KEY	
'********************'
SECURE_BROWSER_XSS_FILTER	
False
SECURE_CONTENT_TYPE_NOSNIFF	
False
SECURE_HSTS_INCLUDE_SUBDOMAINS	
False
SECURE_HSTS_SECONDS	
0
SECURE_PROXY_SSL_HEADER	
None
SECURE_REDIRECT_EXEMPT	
[]
SECURE_SSL_HOST	
None
SECURE_SSL_REDIRECT	
False
SERVER_EMAIL	
'root@localhost'
SESSION_CACHE_ALIAS	
'default'
SESSION_COOKIE_AGE	
1209600
SESSION_COOKIE_DOMAIN	
None
SESSION_COOKIE_HTTPONLY	
True
SESSION_COOKIE_NAME	
'sessionid'
SESSION_COOKIE_PATH	
'/'
SESSION_COOKIE_SECURE	
False
SESSION_ENGINE	
'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE	
False
SESSION_FILE_PATH	
None
SESSION_SAVE_EVERY_REQUEST	
False
SESSION_SERIALIZER	
'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE	
'mysite.settings'
SHORT_DATETIME_FORMAT	
'm/d/Y P'
SHORT_DATE_FORMAT	
'm/d/Y'
SIGNING_BACKEND	
'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS	
[]
STATICFILES_DIRS	
[]
STATICFILES_FINDERS	
['django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE	
'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT	
'/home/ryan/apps/kingsway/content/static'
STATIC_URL	
'/static/'
TEMPLATES	
[{'APP_DIRS': True,
  'BACKEND': 'django.template.backends.django.DjangoTemplates',
  'DIRS': [],
  'OPTIONS': {'context_processors': ['django.template.context_processors.debug',
                                     'django.template.context_processors.request',
                                     'django.contrib.auth.context_processors.auth',
                                     'django.contrib.messages.context_processors.messages']}}]
TEST_NON_SERIALIZED_APPS	
[]
TEST_RUNNER	
'django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR	
','
TIME_FORMAT	
'P'
TIME_INPUT_FORMATS	
['%H:%M:%S', '%H:%M:%S.%f', '%H:%M']
TIME_ZONE	
'America/Vancouver'
USE_ETAGS	
False
USE_I18N	
True
USE_L10N	
True
USE_THOUSAND_SEPARATOR	
False
USE_TZ	
True
USE_X_FORWARDED_HOST	
False
USE_X_FORWARDED_PORT	
False
WSGI_APPLICATION	
'mysite.wsgi.application'
X_FRAME_OPTIONS	
'SAMEORIGIN'
YEAR_MONTH_FORMAT	
'F Y'
_REGISTRATION_ADMIN_REQ_ATTR_NAME_IN_MODEL_INS	
'_registration_admin_request'
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard page generated by the handler for this status code.

model:

class Product(models.Model):
    # Description
    name 						= models.CharField(max_length=200)
    description 				= models.TextField(blank=True)

    # Price
    price 						= models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True)
    cost_markup 				= models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True)

    cost_msrp 					= models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True)
    cost_wholesale 				= models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True)
    cost_distributor 			= models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True)
    
    cost_discount_msrp 			= models.IntegerField(blank=True, null=True)
    cost_discount_wholesale 	= models.IntegerField(blank=True, null=True)
    cost_discount_distributor	= models.IntegerField(blank=True, null=True)

    # Specs
    model 				= models.CharField(max_length=32, primary_key=True) 		# PRIMARY KEY
    sku 				= models.CharField(max_length=32, blank=True)				# Vendor Part Number
    upc 				= models.BigIntegerField(blank=True, null=True)
    slug 				= models.SlugField(('slug'), max_length=60, blank=True)

    # Specs
    dimensions_length 	= models.IntegerField(blank=True, null=True)
    dimensions_width 	= models.IntegerField(blank=True, null=True)
    dimensions_height 	= models.IntegerField(blank=True, null=True)
    dimensions_depth  	= models.IntegerField(blank=True, null=True)
    weight 				= models.DecimalField(max_digits=6, decimal_places=2, blank=True, null=True)

    # Inventory
    qty_on_hand 		= models.IntegerField(default=0)

    # Data
    active 				= models.BooleanField(default=False)
    date_created 		= models.DateTimeField(
        default=timezone.now, editable=False)
    date_updated 		= models.DateTimeField(auto_now=True)

    dwo_choices 		= ('Supplier', 'Us', 'Active')
    dwo 				= models.CharField(choices=Choices(*dwo_choices), max_length=24, blank=True, default='Active')

    # Selectors
    themes 				= models.ManyToManyField(	Theme, 			related_name='products', blank=True)
    colors 				= models.ManyToManyField(	Color, 			related_name='products', blank=True)
    product_types 		= models.ManyToManyField(	ProductType, 	related_name='products', blank=True)
    designer 			= models.ForeignKey(		Designer, 		related_name='products', blank=True, null=True)
    brand 				= models.ForeignKey(		Brand, 			related_name='products', blank=True, null=True)
    product_class 		= models.ForeignKey(		ProductClass, 	related_name='products', blank=True, null=True)

    class Meta:
        ordering = ['brand__name', 'name']
        permissions = (("can_inv_mgmt", "Can manage inventory"),)

    #Then override models save method:
    def save(self, *args, **kwargs):
        if not self.model:
            #Only set the slug when the object is created.
            self.slug = slugify(self.name) #Or whatever you want the slug to use
        super(Product, self).save(*args, **kwargs)

    def __str__(self):
        return self.model

Incorrect redirection after mass editing

I just installed django-mass-edit, which basically boiled down to mentioning it in urls.py and settings.py. Mass editing works fine, but after the operation, I get redirected to '/admin/modelname' instead of '/admin/appname/modelname'. How can I fix that?

Handle custom form fields

Hi,
Currently an object form is fetched using self.get_form(request, obj) but this results in field errors when you have custom fields which aren't defined in the model. I've been getting around this issue by replacing get_form() with admin_site._registry[model].form but I'm not sure if it's safe.

Alter look-and-feel of mass edit form?

I'd like to find some way to change the appearance of the mass-edit form. I am using django-suit to customise the admin, and this package uses Bootstrap for the forms.

So, for example, a mass-edit form looks like this:
mass

Whereas the normal admin form looks like this:
normal

Support not only numeric object ids

Now, regular expression looks like

^admin/ (?P<app_name>[^/]+)/(?P<model_name>[^/]+)-masschange/(?P<object_ids>[0-9,]+)/$

so mass edit does not work with models using non-numeric primary key.

Don't work at selected record out of active page

If I select all records using top left check box and then I click at "Select all XXX <table_verbose>", all records are selected including these which aren't show at current page. But only records from current page are changed. The rest of them is still the same

Partial replacements?

Just wondering if this functionality is available? e.g. I have a fields containing "foo" - "A foo", "B foo" and I want to replace the "foo" part with another word or remove it altogether.

Push to pypi to fix RemovedInDjango19Warning

After I add 'massadmin' into INSTALLED_APPS I got that error:

.venv/local/lib/python2.7/site-packages/django/contrib/admin/util.py:7: RemovedInDjango19Warning: The django.contrib.admin.util module has been renamed. Use django.contrib.admin.utils instead.
  "Use django.contrib.admin.utils instead.", RemovedInDjango19Warning)

.venv/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py:159: RemovedInDjango19Warning: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
  class ContentType(models.Model):

Add copy / save as new option

It would be great if in addition to writing a change to a bunch of models, it could make a copy of the model with the changed fields as differentiating factor.

Compatibility with Django 1.9: ImportError

In development version of Django 1.9 mass-edit causes following error:

File "env19/src/django-mass-edit/massadmin/massadmin.py", line 34, in <module>
from django.contrib.admin.util import unquote
ImportError: No module named util

It is because modules with backward compatibility were removed - see [release notes](https://docs.djangoproject.com/en/dev/releases/1.9/)

KeyError 'has_view_permission' during template rendering

Django version: 2.1.4
Python Version: 3.6.0
KeyError:
'has_view_permission' is missing "In template .../django/contrib/admin/templates/admin/base.html, error at line 58"

Django 2.1 added a view permission to the default permissions.

Integration with django-suit

This might be a stretch, and I know its "out of the core focus", but I would appreciate it if you could look at the option of providing templates that make mass-edit compatible with the "look and feel" of django-suit. This is the best package I have seen for admin interface customisation, and the developer is working hard to ensure that third-party apps can integrate with it.

https://github.com/darklow/django-suit/
and
darklow/django-suit#3

Thanks!

User feedback if nothing checked

It would be a very good idea if, when a user clicks 'Save', but no options are checked, that a prompt is raised/displayed noting that nothing will be changed ...

Weird compatibility issue with django-autocomplete-light

I have a weird compatibility issue with django-autocomplete-light. When I try to mass edit the following model Select button does nothing. Completely nothing. No messages, no errors in javascript console, nothing. I even tried to debug javascript code but it looks like submit action is never called. When I remove autocomplete_light.modelform_factory it starts working as intended. Weird is that I have another model which uses autocomplete_light form and it works nicely with mass edit.

Model:

class ProductRelation(models.Model):
    KIND_SIMILAR = 1
    KIND_ACCESSORY = 2
    KIND_GIFT = 3
    RELATIONSHIP_KINDS = (
        (KIND_SIMILAR, 'similar'),
        (KIND_ACCESSORY, 'accessory'),
        (KIND_GIFT, 'gift'),
        )
    parent_product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='parent_products')
    child_product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name='child_products')
    kind = models.SmallIntegerField(choices=RELATIONSHIP_KINDS, default=KIND_SIMILAR, db_index=True)

Admin:

@admin.register(ProductRelation)
class ProductRelationAdmin(admin.ModelAdmin):
    list_display = ['parent_product', 'child_product', 'kind']
    list_display_links = ['parent_product', 'child_product']
    form = autocomplete_light.modelform_factory(ProductRelation, exclude=['fake'])

Python 2.1 compatibility

Hi @bufke, I have made few compatibility fixes for Django 2.1, pulled #61 and changed version to 3.2.0, but I don't have permissions to PyPI. Could you please release the new version?

KeyError with excluded fields

When I set the massadmin_exclude on some fields I get a issue with rendering the template.

Django Version: 1.5.4
Exception Type: KeyError
Exception Value:    u"Key 'slug' not found in Form"


build\bdist.win32\egg\massadmin\massadmin.py in mass_change_view
    return ma.mass_change_view(request, object_ids) ...

build\bdist.win32\egg\massadmin\massadmin.py in mass_change_view
    adminForm = helpers.AdminForm(form, self.get_fieldsets(request, obj),                    
    self.prepopulated_fields, self.get_readonly_fields(request, obj)) 

invalid syntax (urls.py, line 4)

Default urls.py with a couple options only default admin setting and then massadmin, but getting an error message saying basically that can't reference .urls in massadmin. I have this setup in settings.py and i did end up having to import massadmin in urls.py to get the reference for massadmin to work. But not .urls

from django.conf.urls import patterns, include, url

from django.contrib import admin
from import massadmin import *

admin.autodiscover()

admin.site.site_header = "FireByte Networks"

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'cms.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(massadmin.urls)),
url(r'^admin/', include(admin.site.urls)),
)

Handling too long URLs by storing the object IDs in session

When many objects are selected for mass edit the URL string can get very long, especially if the model's primary key has many digits or id a uuid.
At some point the URL becomes too long and this will result in a server error.

I have created a pull request that addresses this issue (#62)

Loading templates in Django 1.8+

Howdy!

After initial installation of django-mass-edit in a Django 1.11 app, I'm getting a TemplateDoesNotExist /admin/app/mymodel-masschange/1,2/ error when selecting two items to bulk edit from an admin list page. The docs mention uncommenting django.template.loaders.eggs.Loader from TEMPLATE_LOADERS in settings.py, but TEMPLATE_LOADERS does exist in my settings settings.py. After some research, it looks like the Django template settings got changed in 1.8.

In that upgrade documentation I noticed that I could add a loaders section and, low and behold, my TemplateDoesNotExist error goes away. As a second attempt, I uncommented APP_DIRS and added some loaders and things seem to work.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        # 'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
            # using loaders instead of APP_DIRS to get this stupid eggs thing to work for massadmin
            # we should probably undo this at some point
            'loaders': [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
                'django.template.loaders.eggs.Loader',
            ],
        },
    },
]

So, while this works, it doesn't seem like this is the right way to do things any longer. Any idea what the right way to do this is? Maybe massadmin needs to un-egg itself during install?

This may be related to #65 and #70.

Updating Individual Objects

Hi Burke Software,

This is a lovely app. I'm not necessarily reporting a bug, or even requesting a feature change. I'm trying to find an app, like this mass edit app, that lets me select a set of objects and certain fields, then it presents me with a long page with all the selected objects and the selected fields so I can do quick data entry. I'm sure this is possible with coding, but is there an app out there you know that would do this?

As far as I'm aware, django-mass-edit bulk-edits all the selected objects with the exact same data entered in the form. Correct?

Thank you for both reporting and mass-edit!

keehun

Django mass edit not adding entry to django_admin_log table

Guys,

Could you explain to me how to make django-mass-edit add log entries? I'm trying to audit some mass updates and I really need this feature. Should this plugin do this by default? Or I need to add some extra code by myself?

Anyone also has this particulary problem?

Integrate with Grappelli (for nice date / time picker)

Grappelli offers a very nice style and interaction enhancements for the Django admin site.

In particular, it adds a modern and friendly date & time picker which I would like to make available when doing a mass edit.

I believe that Grappelli adds these via Javascript so it may be possible to help Grappelli recognize the mass edit datetime picker and do the same thing.

Thoughts?

Custom readonly_fields crash mass edit template

I often add read-only fields that are links to related models. Any such thing causes a crash when rendering the mass edit form, due to the field having no associated attribute.

Like so:

class MyAdmin(ModelAdmin):
    def other_model_link(self, instance): 
        if instance.other_model:
            other_url = reverse('admin:other_model_change',
                                args=[instance.other_model.id])
            return '<a href="%(url)s">%(description)s</a>' % {
                'url': other_url,
                'description': html.escape(instance.other_model)
            }
        else:
            return '(no other model)'
    other_model_link.allow_tags = True
    other_model_link.short_description = 'Other Model'
    other_model_link.admin_order_field = 'other_model_ordering_field'

    readonly_fields = ['other_model_link']
    ...

And the underlying error that crashes the template is AttributeError: Unable to lookup 'other_model_link' on MyModel.

-- Kenn

massadmin + django-denorm leads to performance problems... make them async?

Hi there,

I am using this package with initcrash/django-denorm and I have a problem with their interaction. It can be fixed by either package, and both fixes are useful.

Denormalization is asynchronous except when a model is saved directly. Massadmin saves the model directly, causing all denormalization to be synchronous.

Solutions:

  • Do not denormalize synchronously even when using save()
  • Turn off denormalizations for a bit during massadmin

These are sort of the same solution - it will involve disconnecting a signal and then reconnecting it, or something like that. I have not figured out the best way.

  • Perform the massadmin edits asynchronously, such as via Django-RQ

I like this, because (a) massadmin seems to be a more active project with easier to understand code and (b) I already use django-rq for lots of asynchronous things such as some manual denormalization that is too hard to express with django-denorm.

So I am already working on this solution and it is mostly done except for troubling pickling various things. I wonder if you have opinions about this problem before I proceed further.

Cheers,

Kenn

id Problem

I have some models with my own primary key definitions.
After trying to mass update i get error:

FieldError ....
Cannot resolve keyword 'id' into field.

.../massadmin/massadmin.py in mass_change_selected
...55. selected_int = queryset.values_list('id', flat=True)

I changed 'ID' to 'PK' in massadmin.py and it works:

..55. selected_int = queryset.values_list('pk', flat=True)
..56. #selected_int = queryset.values_list('id', flat=True)

Is this project alive?

Iā€™m using this app in production and have an interest in keeping it updated and maybe evolving as well. So thank you for a great app @bufke et al.

There is a PR that I made 6 months ago which still got no reply. I totally understand the limitations of 24 hours in a day, believe me! Iā€™m just wondering about the state of this app and if there is anything I can do to help keep the app alive.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.