Category "django-rest-framework"

DRF show different fields on 'list' and 'get_object' [duplicate]

I am using viewsets like this: class UserViewSet(viewsets.ModelViewSet): """Viewset for model User.""" queryset = User.objects.all()

django channels WebsocketCommunicator TimeoutError

I am trying to run the following test: tests.py from rest_framework.test import APITestCase from myapp.routing import application from channels.testing import W

filefield serializer is not parsing the file object

I have a model in my application: class GRNRFIDSerials(models.Model): grn = models.ForeignKey(Grn, on_delete=models.CASCADE) file = models.FileField(up

How to check if a request consists of session id and csref token in the cookie in Django rest framework?

my rest_framework authentication and permission classes "DEFAULT_PERMISSION_CLASSES": [ "rest_framework.permissions.IsAuthenticated", "rest_fra

Nested Category In django

how do I use nested categories in django as Im nwe to django and doing this and find some solutions but didnt work anything class MainCategory(models.Model)

Object of type <> is not JSON serializable Django REST Framework

I am trying to create a search function inside my class-based view using Django Rest Framework, but it does not seems to work. when I try to search for some cus

Why did the Django model return an empty queryset in the thread pool?

I used ThreadPoolExecutor in my API. in the test case, I generated a Movie instance and saved it in the database (PostgreSQL). I printed movie count in the test

csrf cookie not set on linux

I know this question is quite popular, before asking it, I researched all the previous questions and their answers, but never found a solution for myself. My pr

How to login with mobile/otp using Django Oauth Toolkit

We are using Django OAuth Toolkit with DRF(Django Rest Framework). Now, we want to provide login with mobile number. To authenticate we'll use OTP(One Time Pass

Problem while using mypy with my django project

I have implemented mypy in my django rest framework but I am getting errors ModuleNotFoundError: No module named 'config' while running mypy.Is there any wrong

Endpoints sharing part of an URL

I'm currently building an API with Django Rest Framework and I want to have two viewsets. One related to my User model, and one single route to verify a User em

Multiple Token Authentication in Django Rest Framework

How can a user login in multiple devices because what we have is just a single Token Authentication on our django app. As an authenticated user when I login on

Django custom model Interger extrafield not saving in the database return None instead

my models class UserManager(BaseUserManager): def create_user(self, email, password=None, **extra_fields): print(phone_number, 'phone_number')

How to manually customize parameters of DRF views using drf-yasg Swagger?

I am using drf-yasg package to integrate Swagger with DRF. As documentation said I used @swagger_auto_schema decorator to manually customize auto-generated endp

How to POST multiple objects in one JSON request?

I am using django-rest-framework and recently I encountered a problem. I need to post such request and get 2 objects created: { "lease": 28, "date": [

How can I use a third-party API which has basic authentication (username, password) in Django?

I have one third-party API (a URL). To access that URL I have to give basic authentication which is username and password. How can I get data from that API usin

Django testing rest-framework: APIRequestFactory vs APIClient

Being new to testing i'm looking to test my API in Django (Django-rest-framework). I'm setting up tests for my views, that is my API endpoints. Now looking ov

vuejs 401 unauthorized with axios from django backend with token

im trying to fetch data from django rest backend with axios in vuejs frontend but each time i get this error. the tokens match but it is still not authorizing.

Error message "`coreapi` must be installed for schema support"

I am trying to generate Swagger documentation using drf_yasg and it was working fine, but now it’s not. It’s giving me an error and I can not find a

'CityListViewSet' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method

I am assuming by the error in the title, once more here for clarity 'CityListViewSet' should either include a `serializer_class` attribute, or override the `g