Skip to content

Commit 0aa5c4d

Browse files
committed
[fix] Additional check for registered model
1 parent 4bb281f commit 0aa5c4d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

openwisp_controller/mixins.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ class AutoRevisionMixin(RevisionMixin):
4444
revision_atomic = False
4545

4646
def dispatch(self, request, *args, **kwargs):
47-
if request.method in ('POST', 'PUT', 'PATCH') and request.user.is_authenticated:
47+
qs = getattr(self, 'queryset', None)
48+
model = getattr(qs, 'model', None)
49+
if (
50+
request.method in ('POST', 'PUT', 'PATCH')
51+
and request.user.is_authenticated
52+
and model
53+
and reversion.is_registered(model)
54+
):
4855
with reversion.create_revision(atomic=self.revision_atomic):
4956
response = super().dispatch(request, *args, **kwargs)
5057
reversion.set_user(request.user)

0 commit comments

Comments
 (0)