Category "django-rest-framework"

How to set max length on integerfield Django Rest

Okay so I need to have my field have a maximum of 10 integers allowed to be entered. I tried MaxValueValidator but I figured out that this just needs a value th

CSRF cookies not set - React, JWT, Django

I'm rather confused regarding the following error: "Forbidden (CSRF cookie not set.)". This error is received during attempting to logout, login, signup. The pr

How to create a persigned url for a private s3 bucket using django rest framework

models.py def upload_org_logo(instance, filename): ts = calendar.timegm(time.gmtime()) filepath = f"Timesheet/org_logo/{ts}" if instance: b

how can i filter data between two time i am using date time field for it in django rest framework

I am trying to filter my data with a date-time field, but in my case its not working. So please someone suggest to me how can I filter my date with time start_t

Django filtering on a queryset not working

I am trying to add a filter on an existing queryset based on a condition but it doesn't work. This works queryset = None if self.is_instructor =

Django: how to count posts related to a category in django?

i have a model class Category and also a model class Course. i want to count all the courses that are related to a model e.g: Web Devlopment - 26 Courses i dont

Django WebSocket DISCONNECT /ws/chat/lobby/ [127.0.0.1:3022]

i want to create chat app, i follow the https://channels.readthedocs.io/en/latest/tutorial/part_2.html here, chat/ __init__.py routing.py urls.py

Protected Route by checking JWT saved in user's cookie

I just finished implementing Google social authentication in my NextJS + DjangoRest project following this blog post. I am trying to figure out how to make prot

How to get data that belongs to specific user in Django Rest Framework?

I haved Format_List model with relation with Django user and now I want to get the data belongs to specific user by giving user id or after user login. models.p

Django Rest Framework gives 302 in Unit tests when force_login() on detail view?

I'm using Django Rest Framework to serve an API. I've got a couple tests which work great. To do a post the user needs to be logged in and I also do some checks

How can to get data from related model in Django Rest Framework?

I have next models class User(AbstractUser): ip_address = models.CharField(max_length=15) class Statistic(models.Model): user = models.ForeignKey(User

i want connect my sp-api amazon seller and django

hey i try to fix this code for amazon seller sp-api and it's not work at all cannot connect def amazon_list(request): #api_request = requests.get('https://j

Change renderer class inside custom pagination in django rest framework

I am using custom renderer class by default in settings.py. For api I check query parameter "page", if it exist then I paginate result else return normal respon

Django - export excel make it faster with openpyxl

I am using Django restframework and I am trying to export excel. My issue is the process is take a lot of time till it generates the excel file. The final file

Getting error while partial update data in drf

Hi Everyone i am creating api for partially update record, but getting error [patch() missing 1 required positional argument: 'id'], please help me out views.py

DRF/Multi-tenant - How to specify tenant host (domain) in unit tests?

Environment - Django, Rest Framework, Multi-tenant. In my unit tests, I'm trying to hit an endpoint in a tenant schema (not in Public). It is failing because

Django PageNumberPagination customize error if page number out of range

I'm currently trying to create an API that return list of objects with page and limit per page input from url parameter using django-rest-framework which i alre

Django override the error message that Django shows for UniqueConstraint error?

I want to customize Meta class constraints default message. Here is my model that I have been working out. class BusRoute(BaseModel): route = models.Foreign

django filter for NOT IN as lookup_expr

We can make the django filter with "in" expression sending comma separated string. Such as import django_filters class NumberInFilter(django_filters.BaseInFilt

Django. ''The `actions` argument must be provided when calling `.as_view()` '' when I try to allow DELETE, PUT, ETC

I have to allow delete and update requests from front for my objects of some model. I wish to delete instance and appropriate row in DB. I tryed to use info fr