Questions tagged [django-rest-framework]
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.
I try to multiply price and quantity. but somethings went wrong.
'quantity' and 'price' both is IntegerField()
def get(self, request):
bill = ...
I got this error message on Django-rest-framework.
JSON parse error - Expecting property name enclosed in double quotes: line 1 column 2 (char 1)"
Its cause must be single quote, but I passed the ...
I am trying to restify my backend using django-rest-gis, in such a way that POST request adds data to database and GET request lists down the data. However, I am getting following error:-
I am trying to implement a serializer that returns a parent record with its children embedded in the response json object.
My model for the parent and child are both based on database views:
I have the following models:
test = models.ForeignKey(Test, on_delete=models.CASCADE)
text = models.CharField(max_length=255,default='',blank=False)
number = ...
I want to follow django rest framework. And create an API which has an url like 'electronics/1/stock/' where electronics and stock both are models in django admin.
I am dealing with an assignment, which needs to request a third party API and take a few bites of the response and update their keys and render as DRF response.
Can this be achieved via serializers?
I want response a simple Json when clint have permission. (I don't want retrieve model instance). It will be better if you can offer class-base view from restframework (generic or APIView or Viewset ...
When I try to put values in to databse, I am getting this error.
raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.name, kwarg))
TypeError: Employee() got an unexpected ...
I am new to django and reactjs and I am trying to POST request using axios but I am unable to send data. I am getting console error
POST http://localhost:8000/api/todos/ 400 (Bad Request)
this is my ...
I am learning about SuccessFactors employee central API's. I want to upsert entities using postman. But I cannot find any resource about how to filter out all entities which can be upserted. Is there ...
I am trying to create a set of endpoints that are not related to models in Django. I am using Oauth2 for authentification and I am getting all the time 403 error asking for missing permissions.
I want to use an uuid in my API to identify the request for a log implementation, there is any tool for it ??
I look up into the DRF documentation but i did not found anything
I have a project and now i want add a my new endpoint to this project that response a json . this json is very simple and not need to any serializer or queryset.but i dont know how i can use ...
I'm struggling to figure out how timezone works in Django. On my systems I have all datetimes in UTC+00 even with a UTC+02 TIME_ZONE setting.
I am using Django ORM to query a database called Product having column name price(Decimal) and stock_units(int). I want to Multiply both of the columns and get the accumulated summation.
report = ...
How to add a django rest framework authentication in Route?
I am using JWT for authentication of my application.
Everything works perfectly.
What I need to know is how can I authenticate a ...
I'm trying to add social login to my django-rest-framework app, but I'm stuck on this problem and need some help.
Login Flow: Request code(GET) -> Response -> Request token(POST)(This part is where I'...
I am trying to create login api with LoginSerializer and LoginAPIView using django-rest-auth, can anyone please explain the steps on how to do it?
I have a model that stores a text.
I have another related model that is supposed to store the entities in the first model.
For example suppose I am posting a text like "France is in Europe", which ...
This is my update api view:
serializer_class = CountSerializers
def get_queryset(self, *args, **kwargs):
id = self.kwargs.get('pk')
Is there a way to validate params that are passed with the request without writing boilerplate code? Now I've got something like this:
project_id = kwargs['project_id']
After upgrading to Django REST framework 3.7 I got following error
File "/home/jpg/Projects/django2x/sample/views.py", line 24, in <module>
from rest_framework.filters import ...
Maybe my question has already been answered, but I could not find anything.
Lets say that Im building a stock inventory system using Django + Django REST for the backend. To supply this I have this ...
I'm using DRF and trying to search a mapping table for exact matches so I can update that record.
I have the following tables:
In one app, I have the following ViewSet:
class MyViewSet(MyGenericViewSet, ListModelMixin):
queryset = MyModel.objects.all()
serializer_class = MyModelSerializer
Desde Django como backend, quiero crear un token que expire normalmente como trabaja JWT pero cuando las peticiones sean de un dispositivo movil, que el token no caduque, alguien tiene alguna idea?
I have a CustomPagination class that can search for a given post data and return the page containing that data. This does work. However, when dealing with tons of data, this might cause performance ...
i am try to get live data from Raspberry pi and showing it to my django template. i could send data by 'requests' library and receiv it by Django REST. but the problem is in my django for example i ...
I have a table with a blob and would like to exclude it from being in the sql call to the database unless specifically called for. Out of the box django includes everything in the queryset. So far ...
I have to change and save value for my model from old value to the new one in var input_val = span.siblings('input').val();. User clicks an icon to edit a value, then he accepted this value clicking ...
In my url conf I have two similar patterns:
urlpatterns = [
path('chat/', views.chat), # create chat
path('chat/message/', views.message), # create message
The second path works as ...
I am making a retweet function and it works quite smooth but I am not able to retweet my own tweets , I am able to retweet other users tweets but not mine
. It shows that matching query doesn't exist.
I am new in Django rest API. I create an API for my project where user can get data from the system via API. I serialize data and pass also but I also want to count the result and pass that value too.
in below code i want add some permission but it doesn't work exactly . when i change permission to "IsAdmin" that work correctly and response "access deny" when i want get TeacherPostStatistic.but i ...
I have a problem with proper handling an exception in Django middleware.
from rest_framework.exceptions import APIException
from rest_framework.status import HTTP_403_FORBIDDEN
I want to get the object from a queryset
accounts = group.get_external_accounts(include_sub_groups=True)
account: StripeExternalAccount = accounts.get(account_id)
I have a model which has 2 fields that will always be unique.
I want to add them both to the 'lookup_field' attribute
I have a pair of parent/children relation models like:
title = models.TextField(null=True)
content = models.TextField(null=True)
author = models.TextField(null=...
Creating my first Django app ever here. I am having a problem with inserting my Route object. Here's my models.py:
location_id = models.AutoField(primary_key=True)
I am using djangorestframework 3.9.2, and djangorestframework-bulk 0.2.1. I am trying to insert 100 objects via a REST POST, and it's submitting way too many queries. Details below.
The model ...
I'm trying to validate a DRF serializer CharField based on the Request object. The value supplied must be checked for uniqueness against other database values, that are filtered based on the Request.
I have to provide a DB status response (which tells if the serializer gets stored or not) after a POST request in ModelViewSet. Please help me perform that in the view.
from django.shortcuts import ...
i setting up facebook qauth
from oauth2_provider.ext.rest_framework import OAuth2Authentication
ModuleNotFoundError: No module named 'oauth2_provider.ext'
after installing django-rest-framework-...
I'm hitting some third Party APIs in Django Rest. Third party provides some data through callbacks.
I'm using JWT authentication for users of the site. Currently my user model is based on email and ...
I'm new to django and rest_framework and attempting to write an application that takes uploaded images and calculates NDVI index
In models.py: InputImage model is written, that is just meant for ...
I have an Administrator model associated with three other models through generic relationship.
status = (
I'm trying to save a validated serializer in my PostgreSQL 11.0 Database using djangorestframework. Restframework's .save() method is returning an object with a unique PK(+1 sequence) but the object ...
At first you see my 4 method class in view.py:
queryset = Contact.objects.all()
serializer_class = ContactSerializers
# This is delete method
I'm trying to upload multiple files or images in one field. It's returning one image/file but not multiple objects.
I've tried passing many=True in the serializer. Only one image/file is being saved ...