Vitaliy Kucheryaviy
Vitaliy Kucheryaviy
Hi @eldardamari Pydantic's `by_alias` is not default, you need to enforce it: ```Python class AddResult(Schema): total_sum: int class Config: alias_generator = to_camel allow_population_by_field_name = True @api.get("/add", response=AddResult, by_alias=True) #
I guess you can extend Router class: ```Python class MyRouter(Router): def api_operation(self, *a, **kw): kw['by_alias'] = True return super().api_operation(*a, **kw) router = MyRouter() ```
The biggest problem here is that we cannot call `model.clean()` method automatically because you can run your code in async context (and clean is not yet async ready) maybe as...
Hi @lgabs well generally testing django-ninja based project is no different than testing any other django project but, yeah.. I guess I'll add some section about some specific testing tools
Hi @blazing-gig can you show your operation definition ? ```Python @api.post(... def operation(request, ... ```
@blazing-gig @rngallen I think the misunderstanding here is that `ninja.ValidationError` is not the same as `pydantic.ValidationErorr` 1) as for pydantic - I think you do not need to throw exactly...
@rngallen for 404 you can use django's get_object_or_404 ```Python from django.shortcuts import get_object_or_404 ... def update_vehicle(request, truck_id: int, payload: VehicleUpdateSchema): truck = get_object_or_404(Vehicle., id=truck_id)) #
@blazing-gig still thinking... maybe the exception will contain references to original exception... but on the other hand it's almost identical except this patch ``` err["loc"] = [err["loc"][0], err["loc"][-1]] # skip...
but i'm not yet sure how reference will improve here... let's take a case like this: ```Python class Payload(Schema): x: int y: int @api.post('/task/{id}') def do_some_with_task(request, id: int, payload: Payload):...
I guess if you only intereseted in **last** attribute you can just patch loc with ```Python deatais['loc'] = [deatais['loc'][-1]] ```