Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different response classes via klass param #11162

Closed
wants to merge 1 commit into from
Closed

Allow different response classes via klass param #11162

wants to merge 1 commit into from

Conversation

bsolomon1124
Copy link
Contributor

@bsolomon1124 bsolomon1124 commented Apr 2, 2019

Adds a klass parameter to render() that lets user specify a response class other than HttpResponse.

  • Allow any subclass of http.HttpResponseBase
  • Default to http.HttpResponse
  • Do a quick issubclass() check on the argument

Ticket: https://code.djangoproject.com/ticket/30429#ticket

- Allow any subclass of http.response.HttpResponseBase
- Default to http.HttpResponse
- Do a quick issubclass() check on the argument
@bsolomon1124
Copy link
Contributor Author

bsolomon1124 commented Apr 2, 2019

Not sure exactly what's up with the failed checks - something about

Error fetching remote repo 'origin'.

@felixxm
Copy link
Member

felixxm commented Apr 3, 2019

That kind of change requires an accepted ticket.

from django.template import loader
from django.urls import NoReverseMatch, reverse
from django.utils.functional import Promise


def render(request, template_name, context=None, content_type=None, status=None, using=None):
def render(request, template_name, context=None, content_type=None,
status=None, using=None, klass=HttpResponse):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response_class instead of klass?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I am kind of indifferent, just used klass because I have seen it in other libraries. I'm not seeing any evidence empirically that Django has a preference but maybe it does.

@felixxm
Copy link
Member

felixxm commented May 2, 2019

Closing per ticket.

@felixxm felixxm closed this May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants