💨 Fast, Async-ready, Openapi, type hints based framework for building APIs

Overview

Fast to learn, fast to code, fast to run

Test Coverage PyPI version

Django Ninja - Fast Django REST Framework

Django Ninja is a web framework for building APIs with Django and Python 3.6+ based type hints.

Key features

  • Easy: Designed to be easy to use and intuitive.
  • Fast: Very high performance thanks to Pydantic and async support.
  • Fast to code: Type hints and automatic docs let's you focus only on business logic.
  • Standards-based: Based on the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
  • Django friendly: (obviously) have good integration with Django core and ORM.
  • Production ready: Used by multiple companies on live projects (If you use django-ninja and would like to publish your feedback - please email to [email protected])

Django Ninja REST Framework

Documentation: https://django-ninja.rest-framework.com


Installation

pip install django-ninja

Usage

In your django project next to urls.py create new api.py file:

from ninja import NinjaAPI

api = NinjaAPI()


@api.get("/add")
def add(request, a: int, b: int):
    return {"result": a + b}

Now go to urls.py and add the following:

...
from .api import api

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", api.urls),  # <---------- !
]

That's it !

And you already have:

  • API that receives HTTP GET request at /api/add
  • Takes, validates and type-casts GET parameters a and b
  • Decodes to JSON operation result
  • Generates an OpenAPI schema for defined operation

Interactive API docs

Now go to http://127.0.0.1:8000/api/docs

You will see the automatic interactive API documentation (provided by Swagger UI):

Swagger UI

Next

Comments
  • Unable to upload file (always get 'field required' message)

    Unable to upload file (always get 'field required' message)

    Hi @vitalik, I'm trying to upload a file but it's always getting a "field required" message.

    Screenshot from 2021-08-15 08-55-14

    Handler:

    FileParam = File
    def file_create(request: HttpRequest,
            name: str = FileParam(..., max_length=100),
            description: Optional[str] = FileParam(None, max_length=500),
            file: UploadedFile = FileParam(...),
            folder: Optional[UUID] = FileParam(None)
        ):
    

    Has anything been missed?

    opened by aprilahijriyan 17
  • Authentication Docs Error

    Authentication Docs Error

    image image

    I am trying to use Django Auth system, but the Docs are not working on POST/PUT requests and also on Django core admin requests.

    Config:

    api = NinjaAPI(csrf=True, auth=[django_auth])
    

    The only way I could do to access and execute a POST on the Swagger documentation is by adding @csrf_exempt decorator from django.views.decorators.csrf

    @router.delete('/v1/auth/logout/', auth=None)
    def auth_logout(request):
        logout(request)
        resp = HttpResponseRedirect('/')
        # trocar o método para GET -> 303
        resp.status_code = 303
        return resp
    
    
    @router.post('/v1/auth/status/')
    @csrf_exempt
    def auth_status(request):
        if request.user.is_authenticated:
            return True
        else:
            return HttpError(401, 'Unauthenticated')
    

    I already tryed commenting django.middleware.csrf.CsrfViewMiddleware, but doest work.

    Is there a way to use django_sessions with documentation working on POST requests and default admin endpoints? if not, just allow us to use django_auth without forcing to enable CSRF token pls.

    opened by luizfelipevbll 13
  • Smarter schema that handles dotted aliases and resolver methods

    Smarter schema that handles dotted aliases and resolver methods

    Fixes #291 (even though it was closed) and fixes #250 and adds in new functionality to allow calculated fields via resolve_ static methods on the response schema class.

    Includes tests and docs.

    opened by SmileyChris 12
  • Looks like you created multiple NinjaAPIs

    Looks like you created multiple NinjaAPIs

    Hi there, I was playing around a bit with the basic tutorial (it worked perfectly in the beginning) and got this error at some point:

      File "/django/django_aia_backend/django_aia_backend/urls.py", line 31, in <module>
        path('api/', include(api.urls)),
      File "/djangovenv/lib/python3.9/site-packages/ninja/main.py", line 314, in urls
        self._validate()
      File "/djangovenv/lib/python3.9/site-packages/ninja/main.py", line 398, in _validate
        raise ConfigError("\n".join(msg))
    ninja.errors.ConfigError: Looks like you created multiple NinjaAPIs
    To let ninja distinguish them you need to set either unique version or url_namespace
     - NinjaAPI(..., version='2.0.0')
     - NinjaAPI(..., urls_namespace='otherapi')
    Already registered: ['api-1.0.0']
    

    not sure what is the problem here. I only have one instantiation of NinjaAPI. I tried giving it a specific version name but that does not change anything.

    To be fair, I played around a bit before, among other things creating a django app called 'api' for using standard DRF. I deleted this and every reference to it, but even after starting a brand new django project, the error persists. Does the api instantiation get persisted somewhere in venv? I cannot explain otherwise why this happens.

    opened by Raketuv 12
  • ModelSchema typing

    ModelSchema typing

    Nice project. Good to see the ideas from FastAPI get integrated with Django.

    The problem, when using ModelSchema, an IDE like pycharm does not autocomplete the generated schema.

    class CustomerIn(ModelSchema):
        extra_field: str
    
        class Config:
            model = Customer
            model_fields = ['name', 'date']
    

    Then

    customer: CustomerIn
    customer.name  # unknown field for the IDE
    customer.extra_field  # ok
    

    Possible workarounds?

    opened by asaff1 11
  • __modify_schema__() missing 1 required positional argument: 'field'

    __modify_schema__() missing 1 required positional argument: 'field'

    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/views.py", line 35, in openapi_json schema = api.get_openapi_schema() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/main.py", line 419, in get_openapi_schema return get_schema(api=self, path_prefix=path_prefix) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 40, in get_schema openapi = OpenAPISchema(api, path_prefix) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 62, in init ("paths", self.get_paths()), File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 77, in get_paths path_methods = self.methods(path_view.operations) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 86, in methods operation_details = self.operation_details(op) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 114, in operation_details body = self.request_body(operation) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 228, in request_body model, remove_level=model._param_source == "body" File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 186, in _create_schema_from_model cast(Type[BaseModel], model), ref_prefix=REF_PREFIX, by_alias=by_alias File "pydantic/schema.py", line 167, in pydantic.schema.model_schema File "pydantic/schema.py", line 548, in pydantic.schema.model_process_schema File "pydantic/schema.py", line 589, in pydantic.schema.model_type_schema File "pydantic/schema.py", line 236, in pydantic.schema.field_schema File "pydantic/schema.py", line 303, in pydantic.schema.get_field_schema_validations TypeError: modify_schema() missing 1 required positional argument: 'field' [28/Oct/2022 10:11:46] "GET /api/openapi.json HTTP/1.1" 500 254519 [28/Oct/2022 10:11:46] "GET /api/docs HTTP/1.1" 200 788 Internal Server Error: /api/openapi.json Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/views.py", line 35, in openapi_json schema = api.get_openapi_schema() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/main.py", line 419, in get_openapi_schema return get_schema(api=self, path_prefix=path_prefix) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 40, in get_schema openapi = OpenAPISchema(api, path_prefix) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 62, in init ("paths", self.get_paths()), File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 77, in get_paths path_methods = self.methods(path_view.operations) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 86, in methods operation_details = self.operation_details(op) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 114, in operation_details body = self.request_body(operation) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 228, in request_body model, remove_level=model._param_source == "body" File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 186, in _create_schema_from_model cast(Type[BaseModel], model), ref_prefix=REF_PREFIX, by_alias=by_alias File "pydantic/schema.py", line 167, in pydantic.schema.model_schema File "pydantic/schema.py", line 548, in pydantic.schema.model_process_schema File "pydantic/schema.py", line 589, in pydantic.schema.model_type_schema File "pydantic/schema.py", line 236, in pydantic.schema.field_schema File "pydantic/schema.py", line 303, in pydantic.schema.get_field_schema_validations TypeError: modify_schema() missing 1 required positional argument: 'field' [28/Oct/2022 10:11:47] "GET /api/openapi.json HTTP/1.1" 500 254519 [28/Oct/2022 10:24:17] "GET /api/docs HTTP/1.1" 200 788 Internal Server Error: /api/openapi.json Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/views.py", line 35, in openapi_json schema = api.get_openapi_schema() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/main.py", line 419, in get_openapi_schema return get_schema(api=self, path_prefix=path_prefix) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 40, in get_schema openapi = OpenAPISchema(api, path_prefix) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 62, in init ("paths", self.get_paths()), File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 77, in get_paths path_methods = self.methods(path_view.operations) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 86, in methods operation_details = self.operation_details(op) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 114, in operation_details body = self.request_body(operation) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 228, in request_body model, remove_level=model._param_source == "body" File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ninja/openapi/schema.py", line 186, in _create_schema_from_model cast(Type[BaseModel], model), ref_prefix=REF_PREFIX, by_alias=by_alias File "pydantic/schema.py", line 167, in pydantic.schema.model_schema File "pydantic/schema.py", line 548, in pydantic.schema.model_process_schema File "pydantic/schema.py", line 589, in pydantic.schema.model_type_schema File "pydantic/schema.py", line 236, in pydantic.schema.field_schema File "pydantic/schema.py", line 303, in pydantic.schema.get_field_schema_validations TypeError: modify_schema() missing 1 required positional argument: 'field' [28/Oct/2022 10:24:17] "GET /api/openapi.json HTTP/1.1" 500 254519

    opened by SaluteGF 10
  • Please make the response model optional!

    Please make the response model optional!

    I always get this on openapi.

    ninja.errors.ConfigError: Schema for status 400 is not set in response dict_keys([200])
    

    when I don't add a specific response model, it shouldn't be validated!

    opened by aprilahijriyan 10
  • foreign-key value failed to be valid integer in NinjaResponseSchema

    foreign-key value failed to be valid integer in NinjaResponseSchema

    ValidationError at /api/order/orders
    6 validation errors for NinjaResponseSchema
    response -> 0 -> customer_id
      value is not a valid integer (type=type_error.integer)
    response -> 0 -> vendor_id
      value is not a valid integer (type=type_error.integer)
    response -> 0 -> vender_product_id
      value is not a valid integer (type=type_error.integer)
    response -> 1 -> customer_id
      value is not a valid integer (type=type_error.integer)
    response -> 1 -> vendor_id
      value is not a valid integer (type=type_error.integer)
    response -> 1 -> vender_product_id
      value is not a valid integer (type=type_error.integer)
    

    my schema is like this:

    class OrderSchema(Schema):
        customer_id: int
        vendor_id: int
        vender_product_id: int
        total_product: int
        total_price: int
        created_on: datetime
        updated_on: datetime
    
    opened by ismohamedi 10
  • ATOMIC_REQUESTS and async views

    ATOMIC_REQUESTS and async views

    First of all, thank you very much for your work on this project. I sincerely hope that you and your family are doing well and I sincerely pray for the resolution of the conflict in Ukraine.

    Describe the bug I'm getting a RuntimeError on my django ninja async views when ATOMIC_REQUESTS is true

    Versions

    • Python version: 3.10
    • Django version: 4.0.3
    • Django-Ninja version: 0.17.0
    # settings.py
    DATABASES["default"]["ATOMIC_REQUESTS"] = True
    
    # api.py
    
    
    @transaction.non_atomic_requests
    @router.post("/flight-hotel-search", response=FlightHotelSearchResult)
    async def flight_hotel_search(request:HttpRequest, criteria: FlightHotelSearchCriteria):
      # there is zero database call done by me in this view
      ...
    
    
    
    # Error
    # RuntimeError: You cannot use ATOMIC_REQUESTS with async views.
    
    opened by Tobi-De 9
  • Why flint instead of poetry? How to contribute?

    Why flint instead of poetry? How to contribute?

    Hi! I want to contribute, but i found that project depends on flint and it seems very unfriendly to me.

    It gave 2 questions to me:

    • Could we add some docs for contributors?
    • Could we move to poetry?
    opened by al-stefanitsky-mozdor 9
  • Returning redirect responses in endpoints

    Returning redirect responses in endpoints

    I recently started using Django Ninja, and encountered a scenario where I need to return a redirect response to another endpoint (though it would be cool if I could redirect to any URL). I couldn't find a way to do this, and was unable to use something like redirect()/HttpResponseRedirect (the error I received was Pydantic-related, but I assume that even if validation was disabled, this still wouldn't have worked).

    Is there a way to do this in Django Ninja?

    opened by itaisteinherz 9
  • Is it possible to combine both DRF and Django Ninja API?

    Is it possible to combine both DRF and Django Ninja API?

    I have currently a Django API project built with DRF. I would like to use async for some endpoints to optimize long API calls. Would it be possible and interesting to migrate some endpoints to Django Ninja async ? While keeping the rest with DRF. So I would change my server from WSGI to ASGI. Maybe my understanding of async is not right and the combination of both is bad, I don't know.

    opened by gschurck 1
  • Custom exception handler with TestClient cannot access request data

    Custom exception handler with TestClient cannot access request data

    I have this custom exception handler for PermissionDenied errors:

    @api.exception_handler(PermissionDenied)
    def permission_error(request, exc):
        if 'team_id' in request.resolver_match.captured_kwargs.keys():
            message = "You do not have access to this team."
        else:
            message = "Forbidden."
    
        return api.create_response(
            request,
            {"detail": message},
            status=403,
        )
    

    I'd like to customize the error messages based on information in the request. But using the TestClient, the request is a Mock instance, so I get an TypeError: argument of type 'Mock' is not iterable when trying to access the request's captured kwargs. Is there a way around this?

    opened by LaundroMat 1
  • Adding examples to docs without creating multiple classes

    Adding examples to docs without creating multiple classes

    Let's say I have a ninja.Schema as such:

    class MySchema(ninja.Schema):
       var1: bool
       var2: str = ''
    

    If I have an end-point that returns this schema, I get nice docs. Which I can customize based on error response:

    @router.post('/test', response={200: MyResponse, 400: MyResponse})
    def test(request):
       # some logic here to determine 200 vs 400
       return 200, MyResponse(var1=True)
    

    I am trying to customize the docs to include example values that make sense. Things you would see under 200 vs. 400

    I know I can probably create a class for 200's and a class for 400's, change some default values. But was wondering if there was anyway to directly change the "example-values" that show up in the automated docs? I'd prefer to keep one schema class, and then just customize the "example-value" field in the docs Thanks!

    For example in FastAPI, the responses argument in the .post() method allow for such customization

    responses={
            200: {
                "model": MySchema,
                "description": "customized description here",
                "content": {
                    "application/json": {
                        "example": {
                            'custom key': 'custom value'
                        }
                    }
                }
            },
    }
    

    I'm not sure if I'm a fan of the verbose FastAPI customization, a class would probably make more sense. I was wondering if maybe an object of the Schema could also be passed?

    Something like:

    response={
            200: MySchema(var1=True, var2='200 message'), 201: MySchema(var1=True, var2='201 message'), 
            400: MySchema(var1=False, var2='400 message')
        }
    

    then allowing return values of 200/201/400 with the same schema , just varying instantiations of the schema class

    opened by cca32 1
  • Allow reversing URLs with multiple operations.

    Allow reversing URLs with multiple operations.

    A pretty glaring shortcoming is that it is impossible to reverse URLs that have been registered with same path, but different operations.

    Using the same path for different operations is a pretty common pattern. It is even used throughout Ninja's documentation.

    @router.get("/{identifier}")
    def detail(request, identifier: str):
        return "ok"
    
    @router.put("/{identifier}")
    def update(request, identifier: str, data: Policy):
        return "ok"
    

    The above is perfectly valid, but reversing update using django.urls.reverse() will result in a NoReverseMatch error.

    This commit is an attempt at solving the issue. N.B. I am not familiar with the internals of Ninja. This is just an experiment.

    opened by strange 0
  • 'api-1.0.0' is not a registered namespace

    'api-1.0.0' is not a registered namespace

    I had a new distribution on my project:

    Api-django ----api ----apps --------persons <-- here is my module ----static

    the api function fine but the docs had this message (''api-1.0.0' is not a registered namespace''), and not work

    opened by greathector7 3
Releases(v0.20.0)
  • v0.20.0(Dec 17, 2022)

    What's Changed

    • Speedup code reload by @hiaselhans in https://github.com/vitalik/django-ninja/pull/624
    • Added a support for openapi ServerObject by @Vaiders in https://github.com/vitalik/django-ninja/pull/574
    • Fix url_namespace -> urls_namespace msg by @SmileyChris in https://github.com/vitalik/django-ninja/pull/519
    • add --sorted flag to export_openapi_schema by @hiaselhans in https://github.com/vitalik/django-ninja/pull/571
    • Set correct media type in docs for custom renderer by @Svenito in https://github.com/vitalik/django-ninja/pull/598
    • Update swagger UI to 4.14.0 by @kabell in https://github.com/vitalik/django-ninja/pull/553

    Documentation

    • Shuffle doc files around by @vpoulailleau in https://github.com/vitalik/django-ninja/pull/543
    • Fix README link to "async support" by @denizdogan in https://github.com/vitalik/django-ninja/pull/545
    • Add repository url in pyproject.toml by @baseplate-admin in https://github.com/vitalik/django-ninja/pull/563
    • Set up doc search by @tssujt in https://github.com/vitalik/django-ninja/pull/572

    Misc

    • remove python 3.6 by @hiaselhans in https://github.com/vitalik/django-ninja/pull/625
    • Bump actions/checkout from 2 to 3 by @dependabot in https://github.com/vitalik/django-ninja/pull/411
    • Bump actions/setup-python from 2 to 4 by @dependabot in https://github.com/vitalik/django-ninja/pull/493
    • Fix failing flit build by @baseplate-admin in https://github.com/vitalik/django-ninja/pull/564

    New Contributors

    • @vpoulailleau made their first contribution in https://github.com/vitalik/django-ninja/pull/543
    • @denizdogan made their first contribution in https://github.com/vitalik/django-ninja/pull/545
    • @baseplate-admin made their first contribution in https://github.com/vitalik/django-ninja/pull/563
    • @hiaselhans made their first contribution in https://github.com/vitalik/django-ninja/pull/571
    • @Svenito made their first contribution in https://github.com/vitalik/django-ninja/pull/598
    • @Vaiders made their first contribution in https://github.com/vitalik/django-ninja/pull/574
    • @kabell made their first contribution in https://github.com/vitalik/django-ninja/pull/553

    Full Changelog: https://github.com/vitalik/django-ninja/compare/v0.19.1...v0.20.0

    Source code(tar.gz)
    Source code(zip)
  • v0.19.1(Jul 20, 2022)

    What's Changed

    • Declare the AuthenticationError exception class in all by @duducp in https://github.com/vitalik/django-ninja/pull/489
    • Small fix for many2many payloads to allow passing primary keys for model fields

    Documentation

    • Docs restructure by @SmileyChris in https://github.com/vitalik/django-ninja/pull/334
    • Add documentation on the .from_orm method by @cltrudeau in https://github.com/vitalik/django-ninja/pull/503
    • Added mutiple items example by @ihelmer07 in https://github.com/vitalik/django-ninja/pull/509

    New Contributors

    • @cltrudeau made their first contribution in https://github.com/vitalik/django-ninja/pull/503
    • @ihelmer07 made their first contribution in https://github.com/vitalik/django-ninja/pull/509

    Full Changelog: https://github.com/vitalik/django-ninja/compare/v.0.19.0...v0.19.1

    Source code(tar.gz)
    Source code(zip)
  • v.0.19.0(Jun 29, 2022)

    What's Changed

    • docs decorator by @vitalik in https://github.com/vitalik/django-ninja/pull/488
    • Allow arbitrary Pagination Output ( alternative #464 @rafonseca ) by @vitalik in https://github.com/vitalik/django-ninja/pull/483
    • Update Redoc related documents by @tssujt in https://github.com/vitalik/django-ninja/pull/462
    • Improves authentication validation to throw an exception by @duducp in https://github.com/vitalik/django-ninja/pull/454
    • Add TestClient note to multiple APIs warning by @srcreigh in https://github.com/vitalik/django-ninja/pull/416
    • Implement implicit reverse url name generation by @SmileyChris in https://github.com/vitalik/django-ninja/pull/361
      • Also pass the router to get_operation_url_name by @SmileyChris in https://github.com/vitalik/django-ninja/pull/486
    • [feat] add superuser session authentication only by @areski in https://github.com/vitalik/django-ninja/pull/351

    New Contributors

    • @tssujt made their first contribution in https://github.com/vitalik/django-ninja/pull/462
    • @duducp made their first contribution in https://github.com/vitalik/django-ninja/pull/454
    • @srcreigh made their first contribution in https://github.com/vitalik/django-ninja/pull/416
    • @areski made their first contribution in https://github.com/vitalik/django-ninja/pull/351

    Full Changelog: https://github.com/vitalik/django-ninja/compare/v.0.18.0...v.0.19.0

    Source code(tar.gz)
    Source code(zip)
  • v.0.18.0(Jun 3, 2022)

    Hello

    Please welcome the new Django Ninja version it has lot of fixes and improvements

    Most notable a HttpResponse typed argument by @SmileyChris

    Now you can manage response behaviour (cookies, headers, streaming) flixible:

    @api.post("/boop")
    def boop(request, response: HttpResponse): # !
        response.set_cookie("beep", "boop") # !
        return True
    

    All changes

    • Provide a temporal HttpResponse typed argument to views by @SmileyChris in https://github.com/vitalik/django-ninja/pull/336
    • UploadedFile inherit from Django's UploadedFile by @OtherBarry in https://github.com/vitalik/django-ninja/pull/400
    • Allow path parameters to be specified at router level by @kaschnit in https://github.com/vitalik/django-ninja/pull/369
    • Added support for postgress specific fields to Model Schema #353
    • Fixed openapi/pydantic versions compatibility #418
    • pre-commit config by @SmileyChris in https://github.com/vitalik/django-ninja/pull/364
    • Access to test response attributes by @stephane in https://github.com/vitalik/django-ninja/pull/402
    • Small optimization and typing improvements by @SmileyChris in https://github.com/vitalik/django-ninja/pull/367
    • Minor typo in tutorial by @stephane in https://github.com/vitalik/django-ninja/pull/387
    • Specify mypy in CONTRIBUTING.md by @OtherBarry in https://github.com/vitalik/django-ninja/pull/401
    • ConfigError: ModelSchema classes requires a 'Config' subclass by @sebastian-philipp in https://github.com/vitalik/django-ninja/pull/382
    • Fix a typing issue by @HoJin9622 in https://github.com/vitalik/django-ninja/pull/404
    • Fix a few typos by @dy3l in https://github.com/vitalik/django-ninja/pull/426
    • Add Redoc support by @kxxoling in https://github.com/vitalik/django-ninja/pull/427
    • Fix typo in docs by @sho918 in https://github.com/vitalik/django-ninja/pull/432
    • Handle class instances in signature.details.is_collection_type by @flaeppe in https://github.com/vitalik/django-ninja/pull/434
    • Upgrade versions of pre-commit hooks by @flaeppe in https://github.com/vitalik/django-ninja/pull/435

    New Contributors

    • @kaschnit made their first contribution in https://github.com/vitalik/django-ninja/pull/369
    • @stephane made their first contribution in https://github.com/vitalik/django-ninja/pull/387
    • @OtherBarry made their first contribution in https://github.com/vitalik/django-ninja/pull/400
    • @sebastian-philipp made their first contribution in https://github.com/vitalik/django-ninja/pull/382
    • @HoJin9622 made their first contribution in https://github.com/vitalik/django-ninja/pull/404
    • @dy3l made their first contribution in https://github.com/vitalik/django-ninja/pull/426
    • @kxxoling made their first contribution in https://github.com/vitalik/django-ninja/pull/427
    • @sho918 made their first contribution in https://github.com/vitalik/django-ninja/pull/432
    • @flaeppe made their first contribution in https://github.com/vitalik/django-ninja/pull/434

    Full Changelog: https://github.com/vitalik/django-ninja/compare/v0.17.0...v0.18.0

    Source code(tar.gz)
    Source code(zip)
  • v0.17.0(Feb 3, 2022)

    This release brings few long awaited features:

    Smarter schema

    Now you can access orm instance attributes inside schema with resolvers:

    class TaskSchema(Schema):
        title: str
        is_completed: bool
        owner: Optional[str]
        lower_title: str
    
        @staticmethod
        def resolve_owner(obj):  # <------- !!!!!!
            if not obj.owner:
                return
            return f"{obj.owner.first_name} {obj.owner.last_name}"
    
        def resolve_lower_title(self, obj):   # <-------- !!!!!!
            return self.title.lower()
    

    Field aliases now support django template variables dotted syntax:

    class TaskSchema(Schema):
        ...
        last_comment: str = Field(..., alias="comment_set.0.text")
    

    Thanks to @SmileyChris

    Pagination output

    Now default paginated output returns a dict with items and count

    You can now override both input and output schemas for custom pagination:

    class CustomPagination(PaginationBase):
    
        class Input(Schema):
            page: int
            
        class Output(Schema):
            items: List[Any]
            total_pages: int
            current_page: int
        
        def paginate_queryset(self, queryset, pagination: Input, **params):
            return {
                'items': ...,
                'total_pages': ...,
                'current_page': ...,
            }
    

    All updates:

    • Improved pagination by @vitalik
    • Smarter schema that handles dotted aliases and resolver methods by @SmileyChris #317
    • Add support for union type in payload by @AkeemMcLennon #301
    • Export OpenAPI schema management cmd by @stefanitsky #288
    • First key derivation optimization by @mom1 #344
    • **kwargs not required anymore for pagination by @mom1 #285

    New Contributors

    • @AkeemMcLennon
    • @stefanitsky
    • @mom1

    Full Changelog: https://github.com/vitalik/django-ninja/compare/v0.16.2...v0.17.0

    Source code(tar.gz)
    Source code(zip)
  • v0.16.2(Jan 20, 2022)

    • Pydantic 1.9.0 support #310 by @antonrh
    • Fix params descriptions visualization in swagger ui #331 by @ldbenitez
    • Improve TestClient json argument-serialization #315 by @johnbergvall
    • Add python 3.10 to test matrix #273 by @jairhenrique
    • Automate github actions update. #274 by @jairhenrique

    Many documentaion fixes and improvements by:

    • @daviddavis
    • @shamaevnn
    • @SmileyChris
    • @antonrh
    • @s3lcuk
    • @idahogray
    • @TaeHyoungKwon
    • @dekoza
    Source code(tar.gz)
    Source code(zip)
  • v0.16.1(Oct 12, 2021)

    • Resolve #229 & #240 reporting dev errors under django dev-server (#242 by @stephenrauch)
    • Allow NOT_SET to survive copy.deepcopy() (#241 by @stephenrauch)
    Source code(tar.gz)
    Source code(zip)
  • v0.16.0(Oct 6, 2021)

    OpenAPI schemas names

    Generating OpenAPI automatically created schema names changed for duplicated names (see #230) Now instead of silence (or exceptions on other cases) django-ninja will just add sequential number suffix to the schema name in OpenAPI spec. For example if you already have schema called "User" and in some other module you create another "User" schema - the second will have name "User2" in openapi json.

    Other

    • Dot in query regression #238 (#239 by @stephenrauch)
    • Fix openapi schema title and description propagation for query, cookie, header, etc #123 (#233 from @stephenrauch)
    • Fix form schema single param #236 (#237 from @stephenrauch)
    • Improve #181, query with list type (#234 by @stephenrauch)
    • Path signature check (#232 by @stephenrauch)
    • Document how to handle empty form fields (#228 by @stephenrauch)
    • Misc fixes (#231 by @ehdgua01)
    Source code(tar.gz)
    Source code(zip)
  • v0.15.0(Sep 18, 2021)

    Major changes

    • Introduced ModelSchema - declarative way to create schemas from django models
    • Allow arbitrary mix of params Body, Form & File w/ multipart. (#226 by @stephenrauch) (also fixes #134, #162, #201)
    • Path params now support Django path converters (#187 by @stephenrauch)

    Other changes

    • Fixed #208 - Missing schema in requestBody (#209 by @stephenrauch)
    • UploadedFile usability #120
    • Types for "urls" property #155
    • Optimize tests (#217 by @mawassk)
    • Better error message for duplicate orm schema names #214 (#215 @stephenrauch)
    • Test coverage for branches (#211 @stephenrauch)
    • Formatting & styling for test files (#218 by @stephenrauch)
    • Documentation improvements (#207 by @eadwinCode, #205 #206 by @johnthagen )
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Aug 14, 2021)

    Hello Everyone,

    This is a very nice release, which includes some new functionality and fixes And more important there are lot of people contributed to this update Thank you

    • Added experimental Pagination support - allows you easely paginate your querysets and customize pages (note - this feature currently in beta and may change a bit in future udpates)
    • Added support for streaming responses (#149 by @ErwinJunge )
    • Mixing simple arguments and models arguments in GET parameters (#178 by @stephenrauch )
    • Handle custom exceptions in authentication (#174 by @dozer133 )
    • Added build_absolute_uri on test client (#168 by @jairhenrique )
    • Typing improvements (#167, #170 by @davidszotten )
    • Fix assertion message (#175 by @igoose1 )
    • Resolve #148, missing wraps(), with a better error message. (#184 by @stephenrauch)
    • Improved documentation on forward refs ( #161 by @stephenrauch )
    • Fixed add_router() to router already attached to API ( #188 by @stephenrauch )
    • Bumped Swagger UI to 3.51.2 ( #192 by @igoose1 )
    Source code(tar.gz)
    Source code(zip)
  • v0.13.2(Jun 5, 2021)

  • v0.13.1(Jun 3, 2021)

  • v0.13.0(May 18, 2021)

    • Fixed create_schema ValueError on pydantic 1.8.2 (#135)
    • Allow collection fields to be identified when an alias is used #133 (by @kierandarcy )
    • New argument custom_fields in create_schema to override or add fields
    • Fixed create_schema Json field (#127)
    • Include ninja TestClient into distributed package
    Source code(tar.gz)
    Source code(zip)
  • v0.12.3(Apr 28, 2021)

  • v0.12.2(Apr 6, 2021)

  • v0.12.1(Mar 26, 2021)

  • v0.12.0(Mar 26, 2021)

  • v0.11.0(Mar 3, 2021)

  • v0.10.2(Feb 2, 2021)

  • 0.10.1(Jan 15, 2021)

  • v0.10.0(Jan 13, 2021)

  • v0.9.7(Dec 25, 2020)

  • v0.9.6(Dec 21, 2020)

  • v0.9.4(Dec 14, 2020)

  • v0.9.3(Dec 14, 2020)

Bootstrap 3 integration with Django.

django-bootstrap3 Bootstrap 3 integration for Django. Goal The goal of this project is to seamlessly blend Django and Bootstrap 3. Want to use Bootstr

Zostera B.V. 2.3k Jan 02, 2023
Django friendly finite state machine support

Django friendly finite state machine support django-fsm adds simple declarative state management for django models. If you need parallel task executio

Viewflow 2.1k Dec 31, 2022
Basic implementation of Razorpay payment gateway 💳 with Django

Razorpay Payment Integration in Django 💥 In this project Razorpay payment gateway 💳 is integrated with Django by breaking down the whole process int

ScaleReal 12 Dec 12, 2022
A Django app for working with BTCPayServer

btcpay-django A Django app for working with BTCPayServer Installation pip install btcpay-django Developers Release To cut a release, run bumpversion,

Crawford 3 Nov 20, 2022
A prettier way to see Django requests while developing

A prettier way to see Django requests while developing

Adam Hill 35 Dec 02, 2022
A set of high-level abstractions for Django forms

django-formtools Django's "formtools" is a set of high-level abstractions for Django forms. Currently for form previews and multi-step forms. This cod

Jazzband 621 Dec 30, 2022
Simple Login Logout System using Django, JavaScript and ajax.

Djanog-UserAuthenticationSystem Technology Use #version Python 3.9.5 Django 3.2.7 JavaScript --- Ajax Validation --- Login and Logout Functionality, A

Bhaskar Mahor 3 Mar 26, 2022
Example project demonstrating using Django’s test runner with Coverage.py

Example project demonstrating using Django’s test runner with Coverage.py Set up with: python -m venv --prompt . venv source venv/bin/activate python

Adam Johnson 5 Nov 29, 2021
Django API without Django REST framework.

Django API without DRF This is a API project made with Django, and without Django REST framework. This project was done with: Python 3.9.8 Django 3.2.

Regis Santos 3 Jan 19, 2022
Neighbourhood - A python-django web app to help the residence of a given neighborhood know their surrounding better

Neighbourhood A python-django web app to help the residence of a given neighborh

Levy Omolo 4 Aug 25, 2022
Basic Form Web Development using Python, Django and CSS

thebookrain Basic Form Web Development using Python, Django and CSS This is a basic project that contains two forms - borrow and donate. The form data

Ananya Dhulipala 1 Nov 27, 2021
A better and faster multiple selection widget with suggestions

django-searchable-select A better and faster multiple selection widget with suggestions for Django This project is looking for maintainers! Please ope

Andrew Dunai 105 Oct 22, 2022
this is a simple backend for instagram with python and django

simple_instagram_backend this is a simple backend for instagram with python and django it has simple realations and api in 4 diffrent apps: 1-users: a

2 Oct 20, 2021
Sampling profiler for Python programs

py-spy: Sampling profiler for Python programs py-spy is a sampling profiler for Python programs. It lets you visualize what your Python program is spe

Ben Frederickson 9.5k Jan 01, 2023
Cached file system for online resources in Python

Minato Cache & file system for online resources in Python Features Minato enables you to: Download & cache online recsources minato supports the follo

Yasuhiro Yamaguchi 10 Jan 04, 2023
A standalone package to scrape financial data from listed Vietnamese companies via Vietstock

Scrape Financial Data of Vietnamese Listed Companies - Version 2 A standalone package to scrape financial data from listed Vietnamese companies via Vi

Viet Anh (Vincent) Tran 45 Nov 16, 2022
Official Python agent for the Elastic APM

elastic-apm -- Elastic APM agent for Python This is the official Python module for Elastic APM. It provides full out-of-the-box support for many of th

elastic 369 Jan 05, 2023
🌟 A social media made with Django and Python and Bulma. 🎉

Vitary A simple social media made with Django Installation 🛠️ Get the source code 💻 git clone https://github.com/foxy4096/Vitary.git Go the the dir

Aditya Priyadarshi 15 Aug 30, 2022
ProjectManagementWebsite - Project management website for CMSC495 built using the Django stack

ProjectManagementWebsite A minimal project management website for CMSC495 built

Justin 1 May 23, 2022
Custom Django field for using enumerations of named constants

django-enumfield Provides an enumeration Django model field (using IntegerField) with reusable enums and transition validation. Installation Currently

5 Monkeys 195 Dec 20, 2022