Skip to content
This repository

Upgrading breaks _autoregister() on proxy model #94

Closed
dannyadair opened this Issue October 18, 2011 · 2 comments

2 participants

dannyadair Dave Hall
dannyadair

Just upgraded from 1.3.3, getting an exception on startup:

 File "/home/danny/.virtualenvs/myproject/lib/python2.7/site-packages/reversion/admin.py", line 85, in __init__
   self._autoregister(self.model, inline_fields)

 File "/home/danny/.virtualenvs/myproject/lib/python2.7/site-packages/reversion/admin.py", line 58, in _autoregister
   follow.append(field.name)

AttributeError: 'NoneType' object has no attribute 'name'

It seems this commit
449da5c
removed the "if field:" check for proxy fields - can this just be put back in?

Cheers,
Danny

Dave Hall
Owner

Hi,

The autoregister thing for proxy models was taken out because, as it turned out, it was somewhat broken. If it was working for you, then excellent! But in a lot of cases it wasn't.

The issue is that django's a bit confused about proxy models. The actual proxy model has it's own ContentType entry in the database, but ContentType.objects.get_for_model(Model) returns the content type of the parent model. I lodged a bug in the Django issue tracker a long time ago about this:

https://code.djangoproject.com/ticket/11154

While this inconsistent handling of content types and proxy models exists, django-reversion is going to give inconsistent behaviour in it's version handling. If you can think of a consistent solution to this issue, I'd love to hear it.

dannyadair

Wow - didn't realise the issue behind this. I just separated User admin into customers and staff - http://www.mahner.org/posts/separating-staff-and-user-accounts-in-djangos-admin/ - and went about daily business. Then reversion broke upon upgrade. Now I understand the issue better, thank you.

I just had a look at this and posted a suggestion on how to fix it in the Django ticket: https://code.djangoproject.com/ticket/11154#comment:23

django.contrib.contenttypes.models.ContentTypeManager._get_opts() needs to respect/preserve a proxy model's app_label, not just traverse up to the non-proxy and use all its meta. Closing this ticket.

dannyadair dannyadair closed this October 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.