Empty user (and comments) field for revisions created outside admin
See original GitHub issueI’m using the 'reversion.middleware.RevisionMiddleware'
middleware setting along with reversion.register(MyModel)
after every model definition.
All my models have a created_by
and updated_by
field.
For objects that are updated through the Django Admin, I get a User and Comments field that is properly filled in.
However, for objects that are created or updated through my own non-admin views, the revision is created (done by the middleware) but there is no User or Comment information. I’m especially interested in the User part.
When having a look at the revisions in the admin, a dash (-
) is displayed in the User and Comments column for those non-admin created/modified objects.
Any idea on what the proper way is to get proper tracking who changed the object, outside the admin?
Note that the created_by
and modified_by
fields seem to be tracked by reversion:
'_field_dict_cache':
{
'modified_by': None,
'title': u'test',
'created': datetime.datetime(2015, 11, 11, 10, 30, 24, 682000, tzinfo=<UTC>),
'modified': datetime.datetime(2015, 11, 11, 11, 1, 20, 515000, tzinfo=<UTC>),
'created_by': 1,
u'id': 1,
},
Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (11 by maintainers)
Top GitHub Comments
Thanks, I’ve corrected the original example. I’ve also corrected the list of HTTP headers. It should be POST, PUT, PATCH.
(This is because accessing request.user in the view will add a Vary: Cookie header, breaking most caching. You don’t want that on every GET request. However, almost all POST, PUT and PATCH requests won’t want caching anyway, so it’s a decent metric to use.)
If there’s interest in this functionality, I could include an official RevisionMixin in the next release of reversion. I’d also cover RevisionMiddleware in deprecation warnings, as it’s really not a good idea to do!