Questions tagged [django-ninja]
21 questions
2
votes
0 answers
Django-Allauth equivalent for Django Ninja?
I am developing a REST API for web application in Django Ninja and one of our project's assumptions is possibility of using Google SSO for authentication.
Is there any equivalent of Django-Allauth for Django-Ninja? I haven't found anything similar…

mik0w
- 116
- 1
- 4
2
votes
1 answer
Django ninja token authentication with djoser
I have implemented CRUD with Django Ninja framework, but now I want auth in my app,
I had installed and config Djoser, so now I can generate tokens, but I don't know how to verify in my CRUD's
class AuthBearer(HttpBearer):
def authenticate(self,…

Arsalan
- 77
- 1
- 8
1
vote
1 answer
Django Ninja Testing
I am trying to create a test for an API I wrote using Django-Ninja.
Here is my Model:
class Country(models.Model):
created_at = models.DateTimeField(auto_created=True, auto_now_add=True)
name = models.CharField(max_length=128, null=False,…

MSH
- 1,743
- 2
- 14
- 22
1
vote
2 answers
Django Ninja api call from inside a django view
I am just learning Django and Django Ninja API. I have created a simple Api to create and read object(s).
models.py
class Person (models.Model):
first_name = models.CharField(max_length=100)
last_name =…

arundeep78
- 159
- 11
1
vote
2 answers
Email Validator in Django Ninja
I found that Django Ninja uses Pydantic.
I have created a Schema from Django model,
class UserSchema(ModelSchema):
class Config:
model = User
model_fields = ["username", "first_name", "last_name", "email"]
class…

CC7052
- 563
- 5
- 16
1
vote
1 answer
Django Ninja API framework Pydantic schema for User model ommits fields
Project running Django with Ninja API framework. To serialize native Django's User model I use following Pydantic schema:
class UserBase(Schema):
"""Base user schema for GET method."""
id: int
username = str
first_name = str
…

Vitalii Mytenko
- 544
- 5
- 20
1
vote
1 answer
Django Ninja API framework Foreing Key ValueError: Cannot assign must be instance
My project running Django 4.1 and Ninja 0.19.1. I'm trying to make a post request via Swagger or Postman and getting an error ValueError: Cannot assign "115": "Offer.currency_to_sell" must be a "Currency" instance.
Post data is:
{
…

Vitalii Mytenko
- 544
- 5
- 20
0
votes
0 answers
Authorization button not appearing in Django Ninja API docs
I am using Django Ninja to build an API, and I am having trouble getting the authorization button to appear in the API docs. I have already added the rest_auth app to my INSTALLED_APPS and add this
REST_AUTH_DEFAULT_AUTHENTICATION_CLASS =…
0
votes
1 answer
how to make a post request for a model with a foreign key in django-ninja using api
My models looks like this:
from django.db import models
class PRODUCT(models.Model):
name = models.CharField(max_length=50)
price = models.FloatField()
def __str__(self):
return f'{self.name}- {self.price}'
class…

invisible
- 1
- 1
0
votes
0 answers
DJANGO: Error ninja.errors.ConfigError: Router@'/xxxxxxxx/' has already been attached to API NinjaAPI:1.0.0
I am running a Django application in Docker when I spinup the docker container I get the error
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
response =…

kenneth Odumah
- 3
- 1
- 4
0
votes
0 answers
Getting "404 Error: Page not Found" in Django-ninja API
I've faced this problem with all APIs for any application in the project.
To be honest, I've no idea what triggers the problem. Probably, wrong import module or mismatch in urls.
I'd like to show you my project structure for better understadning:…

Igor
- 1
- 1
0
votes
1 answer
When using UploadedFile in the PUT method of ninja Router? I get ["detail": \[{"loc": \["body", "profile_in"\], "msg": "field required"]
I'm trying to add an UploadedFile parameter to the PUT method in my Ninja router. The same parameter works perfectly fine with the POST method, but when I try to use it with the PUT method, Ninja returns the error:
Code
422
Details
Error:…

Hassan Ammar
- 1
- 2
0
votes
1 answer
Downloading image created using Pillow with Django
I am creating image using Pillow from text input provided by user. I am using Django and django-ninja to process the data and then send the image to user. It will not show the image and my server will not store the image, the user will get to…

Hazqeel Afyq
- 23
- 5
0
votes
1 answer
Django Ninja API schema circular import error
I have UserSchema:
# users/models.py
class User(AbstractUser):
...
# users/schemas.py
from typing import List
from tasks.schemas import TaskSchema
class UserSchema(ModelSchema):
tasks: List[TaskSchema] = []
class Config:
…

Swix
- 1,883
- 7
- 33
- 50
0
votes
1 answer
How can Django keep an API user logged in without a browser or return token?
https://github.com/mugartec/django-ninja-auth/blob/bf36b4583a37213001131678d5ecda07f92ba2f6/ninja_auth/api.py#L33
It doesn't return any token, so how to does it identify them post-login for subsequent requests?

user3190635
- 41
- 7