Ninja Extra Request Form
If you are unsure how to handle POST requests with content types like application/x-www-form-urlencoded or multipart/form-data in django-ninja-extra, then this guide will be useful to you.
Django-Ninja already covers most of the use cases here here, but I will give you a quick summary here.
Form Data as Parameters
from ninja import Form, constants
from ninja_extra import api_controller, http_post
@api_controller('', tags=['My Operations'], auth=constants.NOT_SET, permissions=[])
class MyAPIController:
@http_post("/login")
def login(self, username: str = Form(...), password: str = Form(...)):
return {'username': username, 'password': '*****'}
- You need to import
Formfrom theninjamodule - Use
Formas the default value for your parameters
Info
For more information about this, visit the Django-Ninja Form Tutorial
Comments
本文总阅读量次
