Skip to content

Commit

Permalink
fix: compatibility with DRF manage.py generateschema (#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Jun 20, 2024
1 parent be012e5 commit 8e9a4ad
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion projectroles/views_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""REST API views for the projectroles app"""

import re
import sys

from ipaddress import ip_address, ip_network

Expand Down Expand Up @@ -257,7 +258,14 @@ class APIProjectContextMixin(ProjectAccessMixin):

def get_serializer_context(self, *args, **kwargs):
context = super().get_serializer_context(*args, **kwargs)
context['project'] = self.get_project(request=context['request'])
if (
not context['request']
and not getattr(self, 'request')
and sys.argv[1:2] == ["generateschema"]
):
pass # allow request being unset when running management command
else:
context['project'] = self.get_project(request=context['request'])
return context

def get_queryset(self):
Expand Down

0 comments on commit 8e9a4ad

Please sign in to comment.