Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin conflict? #13

Open
ScottEAdams opened this issue Mar 9, 2018 · 3 comments
Open

Admin conflict? #13

ScottEAdams opened this issue Mar 9, 2018 · 3 comments

Comments

@ScottEAdams
Copy link

Latest version + django 1.11.10

I have some post_save_changed handlers on a model imported in AppConfig ready as they should. When clicking to create a new object through admin I get the error below.

Full trace

Traceback (most recent call last):
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 551, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 224, in inner
    return view(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/reversion/admin.py", line 177, in add_view
    return super(VersionAdmin, self).add_view(request, form_url, extra_context)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1508, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1408, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1462, in _changeform_view
    form = ModelForm(initial=initial)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/forms/models.py", line 298, in __init__
    self.instance = opts.model()
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/db/models/base.py", line 575, in __init__
    post_init.send(sender=cls, instance=self)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/fieldsignals/signals.py", line 71, in post_init_closure
    self.get_and_update_changed_fields(receiver, instance, fields)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/fieldsignals/signals.py", line 128, in get_and_update_changed_fields
    new_value = field.to_python(field.value_from_object(instance))
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1036, in to_python
    params={'value': value},
ValidationError: [u"'None' value must be either True or False."]
@ScottEAdams ScottEAdams changed the title Reversion VersionAdmin conflict? Admin conflict? Mar 9, 2018
@ScottEAdams
Copy link
Author

Just tried without reversion VersionAdmin and getting the same

Traceback (most recent call last):
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 551, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 224, in inner
    return view(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1508, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
    return bound_func(*args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1408, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1462, in _changeform_view
    form = ModelForm(initial=initial)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/forms/models.py", line 298, in __init__
    self.instance = opts.model()
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/db/models/base.py", line 575, in __init__
    post_init.send(sender=cls, instance=self)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/fieldsignals/signals.py", line 71, in post_init_closure
    self.get_and_update_changed_fields(receiver, instance, fields)
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/fieldsignals/signals.py", line 128, in get_and_update_changed_fields
    new_value = field.to_python(field.value_from_object(instance))
  File ".virtualenvs/example-SpHsjm1P/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1036, in to_python
    params={'value': value},
ValidationError: [u"'None' value must be either True or False."]

@ScottEAdams
Copy link
Author

new_value = field.to_python(field.value_from_object(instance))

seems the issue is with BooleanField that is None because it hasn't been created yet

@craigds
Copy link
Owner

craigds commented Mar 13, 2018

aha, good find 🥇We can probably work around that.

That thing where django's admin instantiates an empty model has caused so many little issues over the years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants