Category "django-rest-framework"

CSRF validation does not work on Django using HTTPS

I am developing an application which the frontend is an AngularJS API that makes requests to the backend API developed in Django Rest Framework. The frontend

TypeError: __init__() got an unexpected keyword argument 'many'

While trying to return a query-set using generic views, I get an error TypeError: init() got an unexpected keyword argument 'many' I am unable to underst

How can I show the StringRelatedField instead of the Primary Key while still being able to write-to that field using Django Rest Framework?

Models: class CrewMember(models.Model): DEPARTMENT_CHOICES = [ ("deck", "Deck"), ("engineering", "Engineering"), ("interior", "Inte

How can I show the StringRelatedField instead of the Primary Key while still being able to write-to that field using Django Rest Framework?

Models: class CrewMember(models.Model): DEPARTMENT_CHOICES = [ ("deck", "Deck"), ("engineering", "Engineering"), ("interior", "Inte

ModelSerializer field validation for empty string

I'm having a problem with django rest framework. My front is posting data to drf, and one of the fields could be null or an empty string "". # models.py class

Stripe parameter_invalid_integer

I am trying to setup PaymentIntents API from Stripe and the amount needed to be passed to the API is very confusing. Stripe Docs: All API requests expect amount

When testing Django REST Framework, why can't I get APIClient.credentials() to authenticate using a token?

I'm writing a functional (not unit) test against a basic API, like so: from decouple import config from rest_framework.test import APIClient, APITestCase clas

LEAD and LAG window fucntions in Django orm, how to apply on single object?

Question is regarding Window functions usage in Django. I have a following model: class EntriesChangeLog(models.Model): content_type = models.ForeignKey(

I am making POST request from flutter app to Django-Rest user and getting null response

I'm a novice at this. I have been making POST requests from my flutter app to Django-Rest user and getting a null response on vendor name as copy pasted below.

django endpoint not returning all fields specified in serializer

This is Source Def: class SourceDefinition(models.Model): source = models.ForeignKey(Source, on_delete=models.DO_NOTHING) special_id = models.IntegerFie

Conditional unique_together in Django

I have following unique constraint in my model. class Meta: unique_together = (('crop', 'order', 'sku'),) But sku may be null in some cases and in th

How to get Request.User in Django-Rest-Framework serializer?

I've tried something like this, it does not work. class PostSerializer(serializers.ModelSerializer): class Meta: model = Post def save(self)

How to register a normal user using django oAuth toolkit

I am using the Django-Oauth-toolkit in my web app development.In that i can able to create new application using django admin panel and created the new admin us

How do you authenticate a websocket with token authentication on django channels?

We want to use django-channels for our websockets but we need to authenticate as well. We have a rest api running with django-rest-framework and there we use to

Django OAuth Toolkit and POSTMAN

I made a django OAuth server using Django OAuth Toolkit. I've setup the code right and when I use CURL in the following way: curl -X POST -d "grant_type=passw

Why can't I add a ManyToMany relation to an object in Django?

I've got an api made in Django which has two models linked by a ManyToMany relation. class Type(models.Model): name = models.CharField(max_length=64) ap

Django Rest framework, how to include '__all__' fields and a related field in ModelSerializer ?

I have two models, one with M2M relation and a related name. I want to include all fields in the serializer and the related field. models.py: class Pizza(mode

ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication'

I am trying to deploy a django app on GCP but when i try to make migrations it gives me this error: ImportError: Could not import 'rest_framework_simplejw

How to dynamically remove fields from serializer output

I'm developing an API with Django Rest framework, and I would like to dynamically remove the fields from a serializer. The problem is that I need to remove them

How to test authenticated POST request with Pytest in Django

I want to test an authenticated post request on an API using Pytest. This is what I am doing so far: def test_auth_user_can_create(self, client):