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.

0
votes
0answers
16 views

Angular not sending emails when connecting with api of django rest framework

I have made an api in Django that ask for the email, subject and message and send the following data to the email provided. My serializer class is as follows: class EmailUser(serializers....
0
votes
1answer
8 views

Using Django web application to be submitted as a project

I have my main project created in Django as a web application, I have completed my coding. So now that I have to submit the project and have to present it. Is there any way I can render it as an ...
0
votes
0answers
5 views

Sharing session variables data between multiple Django Rest Framework APIs

I have two Django APIs. I am setting a session variable in one of the API and trying to retrieve the same session variable data in the other API. But, the problem is that the session variable data can ...
0
votes
1answer
10 views

FileField with instance id in DRF

I don't know why filefield return string that include None when post data. like this http://example.com/room/None/1.jpg My instance id was null on save. In models.py def room_photo_path(...
0
votes
0answers
9 views

Required = False Not Working Django Rest Framework Serializer

I am trying to update userprofile instance. But i am not passing user_groups in json it remove all foreign keys from my user_groups field. So for that i am setting(trying) this - if request.data.get('...
0
votes
1answer
16 views

How to Return Error Message for Every Instance in Bulk (Array of JSON Objects) POST Request?

I am working on Restaurant Ordering Application. Order of items will be created as an Array of JSON object will be POSTed to orderdetail models, but when the stock of any of the item is not sufficient ...
0
votes
1answer
21 views

How to update primary key field using Django Rest Framework

I have set field called cus_id into primary key field which is not AutoField. I need to change pk alon to keep other relevant data for same id should be in same index instead pk alone need to be ...
1
vote
1answer
16 views

How to Change ManyToManyField Name in Serializer

I want to change ManyToManyField Name. user_groups is manytomanyfield. I tried to use ManyToManyRelatedField and also PrimaryKeyRelatedField but it is giving error. How can i change or with data type ...
0
votes
2answers
14 views

How to save Foreign Key values in DJANGO REST?

Let's say i have models like follow. class Department(models.Model): name = models.CharField(max_length=255) class Student(models.Model): department = models.Foreignkey(Department, on_delete=...
0
votes
0answers
32 views

Update Using APIView

I am trying to update Employee. For that i am using two serializers where UserProfile model is related with OneToOneField with User model. But the problem is coming while updating. When i am updating ...
0
votes
1answer
20 views

Error of Required Field In Django APIView

I am trying to Update A Employee. I am able to update also. But the problem is coming a while updating when i am not sending data in body. It is giving error of Required Field. This error is one of ...
0
votes
0answers
9 views

Adding pages to reportlab canvas from a PDF URL

Hi I am trying to add a page to a pdf file that I am building using reportlab and return it using a Django response. The page I am trying to add comes from an external URL. I would like to add the ...
0
votes
1answer
9 views

Creating User model? form.is_valid always returning false

Trying to add new User (using Django default User model). #api/views.py @csrf_exempt @api_view(['GET', 'POST', ]) def signup(request): print(request.POST) if request.method =='POST': ...
-1
votes
0answers
23 views

How to write decorator function inside a permission class?

I want my API to be accessed by everyone but all privileges to be given to faculty. models.py class User(AbstractUser): is_student = models.BooleanField(default=False) is_faculty = models....
0
votes
2answers
36 views

Optimize Django Rest ORM queries

I a react front-end, django backend (used as REST back). I've inherited the app, and it loads all the user data using many Models and Serializes. It loads very slow. It uses a filter to query for a ...
0
votes
0answers
20 views

How to edit a datetimefield by adding/substracting time through django-rest-framework?

I'm creating a small application where Users have their own time that counts down. An admin should be able to add or substract time from the users time. And i need an API endpoint for that. I have ...
1
vote
3answers
30 views

How to correctly set Allow header for a HTTP_405_METHOD_NOT_ALLOWED status code in Django REST framework

I'm currently looking to disable certain methods for an API endpoint - as added security. I'm using the status code that DRF suggests to use, that is for my case, "HTTP_405_METHOD_NOT_ALLOWED" - ...
0
votes
0answers
7 views

Using generic relations in handling images and file of the project

my problem is that i understand how to use generic relation but can't perform it onto uploading multiple images in serializers i tried to use generic relation in uploading media of the project (files ...
0
votes
1answer
24 views

How to do a post request (with data) from Ionic 4 to djangorestframework

I'm trying to do a post request from my ionic 4 projects to the Django backend website. Here is my code Django code models.py This is the class i need to post data to class Item(models.Model): ...
0
votes
0answers
7 views

loggly-python-handler with django dosent send the logs to loggly

i have django app (Django-Rest-Framework) and i want to add integration with Loggly via HTTP. i used the library loggly-python-handler but the logs are not sent to Loggly. i followed the docs: https:...
1
vote
2answers
35 views

How I can test if user have permission for view

I created permission for my view, and its work but I dont know how I can test if patch request will work with user without permission. permission.py class IsObjectCreator(permissions.BasePermission):...
2
votes
0answers
28 views

How to POST ManyToMany Data with Json?

I have a data like this. enter image description here model.py from django.db import models class Diet(models.Model): date = models.CharField(max_length=20) building = models.CharField(...
0
votes
1answer
21 views

How to edit user permission in Django Rest Framework

I am following the tutorial of django Rest Framework. I want to add user-based permission so that only authenticated user can view each user's detail information. Objective : Anyone can view the ...
2
votes
1answer
18 views

Rest API parameters are empty Serializer without model

In my view, I am not able to retrieve parameter coming in the rest API. when i print data i get {'in_text': ''} serializers.py class StandardizerSerializer(serializers.Serializer): in_text = ...
0
votes
2answers
30 views

Django Rename Column In Postgresql

I have messed up my migrations and need to rename a column in my database, is that possible? Im also using docker which means I can't use any graphical interface to change tables in my db. If changing ...
0
votes
1answer
20 views

ModuleNotFoundError: No module named 'allauth'

This is my installed app. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', ...
0
votes
1answer
32 views

how to be authorized to create an object using django rest framework and CreateAPIView?

I have a problem when I want to create an object using CreateAPIView, I get the message: "detail": "Authentication credentials were not provided.". I use rest-auth and rest-authtoken apps. this is ...
1
vote
0answers
26 views

JWT Login Django Rest Framework

I' m trying to create login view with djangorestframework-jwt.When i logged my user (url 'login/') it was fine and everything worked but and switched to another page (url 'post_list') to create a post ...
0
votes
1answer
25 views

how to fix circular import in django?

I'm trying to create an api that uploads an image with an email to the database. But I'm getting an error "raise ImproperlyConfigured(msg.format(name=self.urlconf_name))" Is the problem in my urls.py? ...
0
votes
0answers
6 views

How to eliminate id path parameter in swagger-ui in DRF-YASG for DRF and DJANGO

I'm using DRF-YASG to document API in Swagger and want to customizing/eliminating some fields shown in parameters I'm running the project with Django 2.1.7, DRF 3.9.2 and DRF-YASG 1.14.0. So, I ...
0
votes
1answer
35 views

How to get data from django rest framework request field

I have 2 models: Printer and Check models.py class Printer(models.Model): name = models.CharField(...) api_key = models.CharField(...) check_type = models.CharField(...) ...
1
vote
0answers
23 views

Multiple file upload DRF

I have a requirement which I would like to allow multiple files to be uploaded within the same post request to create an object. I currently have a method of doing this, but after looking at some ...
0
votes
1answer
32 views

Getting response from django rest endpoint (Search bar)

I'm new to django and need to make search bar in my django-react project. Need to take data from input, send it to django and, as response, receive new queryset. I'm using axios and django-rest ...
0
votes
0answers
9 views

HyperLinkedModelSerializer: Could not resolve URL for hyperlinked relationship using view name

I'm new to django and drf and I'm trying to setup a simple api to return the List and Detail views of the "Personality model. I want the urls to use the slug field instead of the default pk. It works ...
0
votes
0answers
24 views

How i can go through database tables inside my django template using “foreign key”

I'm trying to access my database-table inside my django template, but i don't no know the correct syntax to switch from table to another using the foreign key. Note that my view contain one model, ...
1
vote
1answer
32 views

Django urls with https behind nginx proxy

I have django rest framework behind nginx proxy and some frontend on vue js. The problem is that I have urls with "http" but I need it to be "https": "images": [ { "id": ...
0
votes
2answers
60 views

How to give API key to Django model [on hold]

I have to build a web service and API using Django. I was provided with description of models and JSON file with API methods (here). I have decided to use Django REST framework, but this is first time ...
0
votes
1answer
36 views

Django: Changing the date format from JSON data

I'm currently trying to teach myself Django and I'm a little confused on how to modify data from a web API. For example I request an api with a url: api.example.com/events?location=.... And I get ...
0
votes
0answers
13 views

How do I save records to the right schema/tenant?

I'm working on a multi-tenant application in Django, using django-tenant-schemas. However, when I save users, they don't seem to be properly attached to their tenants. When I query the list of users ...
0
votes
1answer
19 views

How to display JSON informations in a ListView (django rest-framework)

I want to display JSON informations in an android app's ListView. I'm using Django Rest Framework , i already serialized my objects and converted the info to JSON format and are accessible via 127.0.0....
0
votes
1answer
12 views

How can I use the jwt token for authentication that i get from my login view

I need to create JWT token authentication, but I don't know how, could you explain me how to do it better or put some examples? my view: class UserLogin(generics.CreateAPIView): """ POST ...
0
votes
0answers
19 views

Unsupported grant type with Django Oauth Toolkit

I'm using the Django Rest Framework with django-oauth-toolkit, When I make a request on POSTMAN, with this body it works fine, { "username":"username", "password":"password", "client_id":"...
0
votes
1answer
34 views

API not sending email

I am trying to build a rest API that will ask for an email, subject and message from the user and send that subject and message to the email provided in the email field, from the email registered in ...
1
vote
1answer
34 views

How to handle an image upload before creating the entry for the account in the database?

I'm building a single page application. On the client side I'm using Nuxt.js (which includes Vue.js and Vuex). To send and receive data to the server I use axios. The API was built with the Django ...
2
votes
1answer
23 views

How to use a action decorator for update?

I need to update my endpoint using a action decorator. What is better way to make a action for update? I have two serializers: class GarageViewSet(viewsets.ModelViewSet): queryset = Garage....
0
votes
0answers
25 views

Django: Incorrect type. Expected pk value, received str

I am using Django Rest Framework to performing get() and post() to an existing database. The Database doesn't have an 'id' field. It has composite primary keys for all the tables and I cannot modify ...
-1
votes
1answer
11 views

ModuleNotFoundError: No module named 'rest_frameword'

when I run manage.py in Django,the problem appearance,and I can't find the answer.
4
votes
4answers
49 views

Truncate the length of model serializer with many=True in Django

So in my project, I have a model Chat with many Messages. I want to have ChatSerializer with MessageSerializer inside and many=True. However, I only want to include the last 50 Message models. class ...
0
votes
0answers
24 views

django-rest-auth: What is the email verification for and how can I let the user activate the account correctly?

I might misunderstand something. django-rest-auth provides RegisterView and an email is supposed to be sent to the user's email after user sign up. However, I've noticed the user is registered with ...
2
votes
1answer
23 views

Djongo not obtaining Object Array embedded fields correctly with Django-rest-framework

I am having trouble displaying the codes array as an embedded field on Django. I am connecting Django up to a MongoDB where there are embedded documents. (See below) Adding the fields in Django ...

http://mssss.yulina-kosm.ru