Questions tagged [django-rest-framework]

Django REST framework is a powerful and flexible toolkit for building RESTful Web APIs. Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Filter by
Sorted by
Tagged with
0 votes
0 answers
6 views

Django ModelViewSet: passowrd not encrypted when using PUT method

I use DRF ModelViewSet for user account CRUD operations. I have "extend" Django user model with Profile model to store complementary user's informations. I have override create and update ...
SLATER's user avatar
  • 591
0 votes
0 answers
6 views

Mayan EDMS ,Calling the API remotely using AJAX getting CORS error

I am creating a new webapp that is going to be making calls to the Mayan EDMS API with javascript/ajax Currently i am getting a CORS error. My mayan installation is running inside a docker container. ...
randy's user avatar
  • 1,695
0 votes
0 answers
10 views

How to send multiple objects on serializers.Serializer (got non_field_errors)

I'm trying to send multiple data through a create viewset method to a serializer. However when doing that I get an error as follows: Error message Im using many attribute into the serializer, but I ...
Juan Trujillo's user avatar
0 votes
0 answers
2 views

django rest framework: Getting "This field may not be null." with FloatField even with blank=True

Here dummy code to show my problem: In my django models.py I have something like: class MyModel(Model): test_field = SlugField(blank=True, null=False) # some other not-null not-blank fields ...
Alfonso_MA's user avatar
0 votes
0 answers
6 views

Can you side-load relations in a Django Rest Framework response?

I have an API endpoint that needs to return many thousands of results that share relations. I would like to return the ID on each result and then return a second set of data containing each of the ...
dubloons's user avatar
  • 1,116
0 votes
1 answer
10 views

How can I add relation values to a serializer in Django Rest Framework?

I would like to return many thousands of results along with one attribute from a relation. I tried including the value in the fields array but got the following error: Field name ...
dubloons's user avatar
  • 1,116
0 votes
0 answers
7 views

Run a "always on" redis keyspace event listener with django

I have deployed a django application on an EC2 instance. I have used NGINX as the reverse proxy and gunicorn as the WSGI server to serve requests from the django app. As part of a functionality within ...
user21970654's user avatar
0 votes
0 answers
16 views

How to serialize two related models in Django

I have two model: class Liver_Function_Tests(models.Model): blood_lab=models.ForeignKey(Blood_Lab,on_delete=models.CASCADE,null=True, related_name='liver_function_tests') class Blood_Lab(...
Hazem Mohamed's user avatar
0 votes
0 answers
21 views

How to remove trailing slash in the URL for API created using Django Rest Framework

I have created a django web-app and created rest apis for the same. Here is the project structure main_project | |___api | |___product this is the urls.py in the main_project. urlpatterns = [ ...
Gerry Volta's user avatar
0 votes
1 answer
27 views

NextJS - cannot pass an API Json list to navigation component

I struggle to create a dynamic navigation component. The navigation items should be consumed from an Rest API generated by the backend (in my case Django). The API relevant address displays the list ...
donbonbon's user avatar
0 votes
1 answer
19 views

Django Rest Framework: All POST APIs only respond with "Forbidden" after logging in a user

After enabling authentication in my Django backend and logging in a user all POST Requests stop to work and only respond with "403 Forbidden". I setup a Django App as my backend and I use ...
Thabb's user avatar
  • 21
0 votes
0 answers
14 views

Unable to send email using celery in DRF

I'm unable to send email via smtp using celery task and DRF. I have the following constants in settings.py # Celery settings CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0' CELERY_RESULT_BACKEND = '...
Srivatsa's user avatar
0 votes
0 answers
13 views

How can I create a user login/registration model using Django Rest Framework without getting a response code 403 when trying to create user?

So I am working on a project using Django and Django rest framework. I'm trying to create an api for my website which allows users to register/log in/log out. I'm following [this tutorial] (https://...
Sophia's user avatar
  • 1
-2 votes
0 answers
24 views

AttributeError: 'list' object has no attribute 'startswith' - Django views

from django.shortcuts import render # Create your views here. def twitter(request): return render(request, 'index.html') def page2(request): cars = ['A', 'B', 'C', 'D'] context = {'cars': ...
Ebrahim Ramadan's user avatar
0 votes
3 answers
27 views

Filter nested Django objects in serializer

In an application I am working on I would like to filter the objects returned by a serializer based on the user's is_staff status. If a user has is_staff = True I would like for all of the nested ...
Jake Mulhern's user avatar
0 votes
0 answers
12 views

Form type request in Postman for API with nested serializers in Django Rest Framework

I need to pass the nested dictionary which is the mixture of text and file. I created the nested serializer to get the data from API request. What will be my request like in Postman? Request Structure:...
Nitesh Ghimire's user avatar
0 votes
1 answer
16 views

Django and ReactJS integration: "Failed to load resource: the server responded with a status of 404 (Not Found)" error

I am working on an e-commerce project where I am using Django for the backend and ReactJS for the front end. However, I am encountering an error when trying to fetch data from the ReactJS component to ...
TechLover's user avatar
0 votes
1 answer
32 views

Django RESTAPI how to make calculation APIs PUT or POST?

Hi I'm trying to make calculation rest api using django. My objective is to save preprocessed_data(result) into the db table field The process is read raw data path(txt file) from db and calculate ...
jihyeon's user avatar
  • 55
0 votes
2 answers
29 views

Using serializer with foreign key model when creating new entry

At first, I had this serializer and it works well for GET and POST(create new entry) class DrawingSerializer(ModelSerializer): drawing = serializers.FileField() detail = serializers.JSONField()...
whitebear's user avatar
  • 10.7k
0 votes
1 answer
23 views

Problems creating in the CustomUser model to authenticate with email and password DJANGO

I am making my first rest_framework platform with django and JWT, the problem that arises is that it is using the username as a password and I want to change it to email which is the generic that ...
Alex V's user avatar
  • 5
0 votes
0 answers
19 views

How would I extract an id from multipart/form-data that has many objects

I am sending formData to upload files in my backend, but I cant seem to extract the file_id for each key from the data. This is the relevant part of my Viewset's code: def patch(self, request, *args, *...
Asif333's user avatar
  • 37
1 vote
0 answers
31 views

Django database error when checking exist email on database mongodb using djongo engine

I made a function to check if email is exist on database, but after accessing on browser with email that already exist in database it show database error but the connection with database isn't the ...
Adrian Glazer's user avatar
0 votes
0 answers
17 views

in my code send_bulkledger call many time ,but i called it only once

if main1['res']['message']['module']=='bulk_ledger_save': ledger_list=await self.save_bulk_ledger(main1) # returns a list print('6000') msgdict= {"msg":&...
ddspl. staff's user avatar
1 vote
0 answers
29 views

Django rest framework: Cascade activate/deactivate

I am working on an API using django and django rest framework, what I want to do is cascading with two action for related models Deleting an instance and that goes smothely with no problem using ...
Mahmoud Said's user avatar
0 votes
0 answers
23 views

Django Rest Framework Serializer Update Method

I have a serializer that I am using to make an update I however cannot seem to make it work. The view is a ModelViewSet, and the main Model is a User model which has a foreign key mapping to a Profile ...
Isaac Hatilima's user avatar
0 votes
0 answers
21 views

Catch and send the Integrity error in the response in Django rest Framework

In the application I want to catch the Integrity error, format it and send to the user for which I am doing something like this: class ProductUploadAPIView(APIView): @transaction.atomic def ...
Rahul Sharma's user avatar
  • 2,087
-3 votes
0 answers
33 views

Facing a Cors error but that is already enabled in Django rest framework and react

I am facing one issue in my app which is developed in react and Django rest framework. In DRF api i am uploading the video and playing in react app. But video player slider not working then i have ...
techno test's user avatar
0 votes
1 answer
48 views

How can I optimize @property method by prefetching or caching an "unrelated" table

I have three model objects, two of which directly relate to each other. class Child(models.Model): date_of_birth = models.DateField() name = models.CharField(max_length=255) gender = ...
Bradleo's user avatar
  • 165
0 votes
0 answers
20 views

how to upload file to server / django rest framework

Thanks to stack overflow, I implemented loading a file in views, but how to make sure that the file gets to the server and data appears in the database. If I upload a file through the admin panel, ...
Alex kX's user avatar
-2 votes
0 answers
20 views

how can i fix this file python.exe [closed]

when I run the server I get this problem which is in the terminal so please help me quickly the error say : "D:\safaa_mostafa\python.exe: can't open file 'C:\Users\ALL IN ONE\Desktop\test\manage....
safaa's user avatar
  • 1
0 votes
1 answer
16 views

drf_spectacular.utils.PolymorphicProxySerializer.__init__() got an unexpected keyword argument 'context'

I am using a PolymorphicProxySerializer provided by drf_spectacular but I am getting a strange error when attempting to load the schema usage @extend_schema( parameters=[...
Austin Hallett's user avatar
0 votes
0 answers
28 views

I want to create testcase for my project but i got this error

this is the testcase i wrote i have user model that records create only with email confirmation so i have to get email code from EmailConfirm model and i can't pass it to test class as self.email_code....
MMEEUR's user avatar
  • 47
0 votes
0 answers
33 views

Informix "Unable to load translation shared library (DLL). SQLCODE=-11048" problem

As the title says, I’ve been trying to connect my application (django rest framework backend deployed on IIS 8 (windows server 12 R2) to Informix but it shows me the same error: [Informix][Informix ...
ImTryingVeryHard's user avatar
1 vote
1 answer
29 views

Managing User Authentication Across Multiple Django Projects with a Custom User Model

I have three Django projects: Project A, Project B, and Project C. Project A serves as the authentication project, Project B is responsible for managing user-related functionalities, and Project C ...
Saadi Mohammed's user avatar
0 votes
1 answer
20 views

Django DRF Serializer slice amount in list of nested field based on user

I want to ask how to slice a nested lists in DRF. I have models Store, Manager, Products. Serializer returns store object with a nested fields. What I want to do is to slice the values, to NOT return ...
Uldis's user avatar
  • 13
0 votes
0 answers
28 views

Integrating Firebase authentication with Django (DRF)

I am developing a Django (DRF)/React web application and have integrated Firebase authentication using the email/password provider. The application requires additional user data, and I aim to link the ...
AminA2's user avatar
  • 168
0 votes
0 answers
18 views

Adding request.user to model field in django rest framework upon form submission

I am working on an app using Django and React and I use DRF to create APIs. I have a form that contains a field called submittedUser that I want it to define the user that posted the form in models.py ...
Mostafa Mohamed's user avatar
0 votes
0 answers
17 views

Receive input in file format from swagger form (Django)

# model class User(AbstractBaseUser, PermissionsMixin, CommonModel): phone = models.CharField(max_length=20, unique=True) nickname = models.CharField(max_length=20, unique=True) ...
aiden's user avatar
  • 33
0 votes
0 answers
29 views

'User matching query does not exist' when adding a like to database

As the title says, I'm trying to make a like button as a many to many where if a certain verse(or post) is liked by a certain user, a like is added to the database, and if a user unlikes a verse, a ...
Soothingcube3's user avatar
0 votes
0 answers
33 views

Can someone please fix my search bar in Flutter?

I'm trying to make a searchbar, where I can search data from my Django API. Right now I can find shows by name, and when I'm deleting my prompt it doesn't update. I would also like to find shows by ...
amyhawks's user avatar
0 votes
1 answer
31 views

Sorting warnings by accumulated count and date within a specified date range in Django

I have a Django project where I need to sort warnings based on the accumulated warning count (warning_count) and the date (date) within a specified date range (start_date and end_date). Here is my ...
chea's user avatar
  • 101
1 vote
1 answer
35 views

Is there a way to exclude fields in nested serializers with a dictfield?

I am trying to serialize a dictionary in the structure of: dict = {'outer_dict': {'inner_dict1': {'key1': 'value1', 'key2': 'value2'}, 'inner_dict2': {'key3': 'value3', 'key4': ...
SHaringT's user avatar
2 votes
1 answer
58 views

Checking if varchar column value containing IP address is in subnet

In SQL (tried in pgAdmin) I am able to do SELECT * FROM ... WHERE inet(s.ip_address) << `10.0.0.2/24` I tried to convert it to django ORM code which contained following: ... .filter(...
MsA's user avatar
  • 2,457
0 votes
0 answers
19 views

Expected a list of items but got type "QuerySet; BaseSerializer

I'm attempting create a read-only serializer as described here in the DRF docs where a custom to_representation() is implemented: https://www.django-rest-framework.org/api-guide/serializers/#read-...
binny's user avatar
  • 639
0 votes
1 answer
23 views

DRF ORM: Aggregate, annotate and remove duplicates all in the same query

Knowing that I have the following models: class Merchant(BaseModel): business_name = CharField() user = ForeignKey( User, related_name='merchant' # ... ) # ...
Muhammad Nihad's user avatar
0 votes
1 answer
31 views

"detail": "Authentication credentials were not provided." Django DRF

Im trying to create an api for my django project to get some data from database and show it as restframework Response everytime I try to get the data it shows me this error this is my views.py code ...
Shervin.bdn's user avatar
-1 votes
1 answer
31 views

Django orm filter many to many fields

The question is this. There are Project and User models. In the Project model, there are 2 ManyToMany links to the users model. class Project(models.Model): name = models.CharField(max_length=100) ...
Дмитрий's user avatar
0 votes
1 answer
27 views

DRF serializer related object with unique constraint

I'm working on an API using django rest framework. I have a Review object that has a job_id FK pointing to a Job object, with a unique constraint on that FK (there can only be 1 review per job). In my ...
Jules Olléon's user avatar
0 votes
0 answers
77 views

ImportError: PyO3 modules may only be initialized once per interpreter process

I am working on a Django project which includes DRF. The application is dockerized. Everything was working fine then suddenly I got the following error in my logs and I am completely clueless how it ...
Muhammad Safwan's user avatar
3 votes
2 answers
32 views

Add a OnetoOne field in an already populated Django ORM

I have this customer model where I want to introduce a user field where the user field is user = models.OneToOneField(User, on_delete=models.CASCADE) but there are already some objects in this model ...
Rahul Sharma's user avatar
  • 2,087

1
2 3 4 5
622