django-rest-framework Questions

3

Solved

I am trying to test my update method on my viewset. The viewset is a modelviewset taken from drf. To update i would need to send a put request. As this is not always supported there are 2 ways to t...

3

Solved

I have a Django project and I am using Django REST framework. I am using drf-spectacular for OpenAPI representation, but I think my problem is not tied to this package, it's seems a more generic Op...
Transgression asked 10/7, 2020 at 8:25

2

Solved

when extending a new Token Authentication class from rest_framework_simplejwt.authentication.JWTAuthentication drf-spectacular swagger-ui authorize button disappears and there is no way to add toke...

3

Solved

I recently ran into the need to disable transaction requests in one of my views, in order to be able to call db.connection.close() and connect() during requests in an effort to improve performance....
Reckon asked 18/4, 2018 at 15:4

4

Solved

Not sure if i'm using the right vocabulary. In the browsable api that comes for free with django-rest-framework, I was wondering if there was a way to autogenerate a form similar to how we define M...
Tintype asked 31/1, 2013 at 0:31

2

Solved

I can't figure out how to pass user object to the following serializer: class ReviewSerializer(serializers.ModelSerializer): user = UserSerializer(read_only=True) class Meta: model = Review f...

16

In my view function, I'd like to return a json object (data1) and some text/html (form). Is this possible? MY code @api_view(['POST']) @permission_classes((AllowAny,)) def create_user(request): if...
Hepzi asked 14/7, 2016 at 6:21

2

Solved

I use Django along with Django REST Framework to implement a RESTful API. What I have right now: A ContentEntry model A ContentEntryCreateUpdateSerializer serializer for my ContentEntry model A ...
Sub asked 3/5, 2017 at 15:19

4

I'm using Django 3, Python 3.8, and the Django Rest framework. Additionally, I'm using the address module from here -- https://github.com/furious-luke/django-address. I have built the following ser...

2

Solved

I have written a code in Python using Django Rest Framework to fetch data from database(MySql) and view it in browser using Pagination(LimitOffSetPagination).But It is not working fine.But when I u...
Aerosol asked 24/6, 2019 at 9:56

4

I am using Django and Django Rest Framework 2.4.0 I get the Attribute error type object 'Notification' has no attribute 'objects' models.py class Notification(models.Model): NOTIFICATION_ID = m...
Padus asked 21/2, 2016 at 23:53

13

Solved

With Django REST Framework, a standard ModelSerializer will allow ForeignKey model relationships to be assigned or changed by POSTing an ID as an Integer. What's the simplest way to get this behav...
Reconciliatory asked 29/4, 2015 at 17:50

10

Solved

If i have a nested serializer: class ChildSerializer(ModelSerializer): class Meta: fields = ('c_name', ) model = Child class ParentSerializer(ModelSerializer): child = ChildSerializer(many=...
Dianoetic asked 31/5, 2015 at 17:33

7

Solved

The docs say you can set trailing_slash=False but how can you allow both endpoints to work, with or without a trailing slash?
Archicarp asked 11/9, 2017 at 20:25

3

Solved

I have a ListAPIView that uses the DjangoFilterBackend to filter rooms based on url parameters. The code below does this just fine. Now, I would like to sort the results based on a score calculat...
Marte asked 1/3, 2018 at 23:29

5

Solved

I am building an API using the django REST framework. To test this API I am using pytest and the test client like so: def test_doesnt_find(self, client): resp = client.post(self.url, data={'name...
Buiron asked 6/10, 2016 at 23:6

4

Solved

I'm using django rest framework and just creating a simple serializer like this: class PackageSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Package fields = ('id', 'u...
Retroflex asked 21/2, 2013 at 23:56

5

So far I'm extremely happy with Django Rest Framework, which is why I alsmost can't believe there's such a large omission in the codebase. Hopefully someone knows of a way how to support this: cla...
Handyman asked 25/10, 2014 at 10:58

4

Solved

What is @csrf_exempt, and why should we use this in our views.py? Also, are there any alternatives to it?
Alveta asked 6/8, 2018 at 14:39

5

Solved

I am managing my User Model (for customers), but i don't know how can i use simple-jwt for my Customer Model with it's custom Login View. models.py from django.db import models class Customer(mode...

3

I am going to create and update nested relationships but it is not working as expected I have a three models User, Profile and Address. Profile model is a FK in Address model profiles/models.py c...
Coexecutor asked 8/8, 2019 at 6:49

6

Solved

I have a serializer in Django REST framework defined as follows: class QuestionSerializer(serializers.Serializer): id = serializers.CharField() question_text = QuestionTextSerializer() topic = ...

10

Solved

I am using Django REST Framework to serialize a Django model. I have a ListCreateAPIView view to list the objects and a RetrieveUpdateDestroyAPIView view to retrieve/update/delete individual object...
Crum asked 2/10, 2013 at 1:49

5

Solved

I'm trying to integrate django validators 1.9 with django rest framework serializers. But the serialized 'user' (of django rest framework) is not compatible with the django validators. Here is the...
Unquestionable asked 4/4, 2016 at 23:51

26

Solved

I m building a flutter app with django rest-framework. The registration api is working fine in Postman but after some successful registration from the flutter app it is showing the above error. The...
Riggs asked 21/4, 2019 at 18:31

© 2022 - 2024 — McMap. All rights reserved.