[Answered ]-Requesting a specific view in Django multitenant API

1👍

It looks like you’re returning raw strings from your views. You need to return instances of HttpResponse (or use render, etc)

For example you have the following:

def get(self, request, *args, **kwargs):
    try:
        organizations = Organization.objects.get(domain_url=request.META['HTTP_HOST'])
        schema_name = organizations["schema_name"]
        #schema_name = organizations.schema_name
    except Organization.DoesNotExist:
        return "no organization"

It’s hitting the return "no organization" code branch which then breaks Django’s middleware expectations.

Leave a comment