Skip to content

Rest views #9696

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

Closed
wants to merge 3 commits into from
Closed

Rest views #9696

wants to merge 3 commits into from

Conversation

Merser4
Copy link

@Merser4 Merser4 commented May 6, 2025

Good afternoon. In this PR, I propose introducing a new type of View for DRF. Why is it needed, and what problem does it solve?

There is ApiView, which can handle multiple HTTP methods for a single URL path, but its functionality is quite limited.

There is ViewSet, which can be used to handle multiple HTTP methods and different URL paths. However, ViewSet is rather overloaded:

  • It is often used with a Router, which requires understanding both the ViewSet and the Router.
  • It does not have an explicit binding to HTTP methods, so you have to keep this in mind.
  • The action decorator with the detail parameter also adds cognitive load.
  • You also need to remember the rules for forming the url_name with the router.

I have implemented RESTView, which can do everything that a ViewSet does, but in a more explicit way and without the need for additional classes. It supports both the Django and DRF interfaces. It can be easily integrated into existing projects.

This implementation still requires more thorough testing. I would like to hear your opinion about this functionality and whether you are open to considering it for DRF. I would appreciate your feedback.

@tomchristie tomchristie closed this May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants