django-rest-framework Questions

2

DjangoRestFramework seems to handle errors with a variety of ways. The ValidationError in the serializer class does not consistently return JSON the same. Current response includes a JSON list/obj...

32

Solved

I've installed django rest framework using pip install djangorestframework yet I still get this error when I run "python3 manage.py sycndb": ImportError: No module named 'rest_framework' I'm u...
Typhon asked 23/10, 2015 at 18:5

3

Solved

I am trying to update my serializers in my drf project to be shown in a nested way. The two models in question are Image and Gallery, images are related to Galleries. I tried following https://www...
Hadlee asked 20/8, 2019 at 9:50

8

Solved

Python/Django n00b moving over from javascript. Trying to add an API endpoint using Django REST Framework which I'm hoping will ultimately be able to update a User with the body of a PATCH request...
Nazarite asked 6/12, 2018 at 10:25

4

I am using DjangoRestFramework 3.3.2 for Routing in my django application. I have 6 different folders for 6 apps and 1 main project app. I have include all 6 apps urls into main url file. Following...
Aubyn asked 16/3, 2017 at 9:18

1

could not derive type of path parameter "id" because it is untyped and obtaining queryset from the viewset failed. Consider adding a type to the path (e.g. int:id) or annotating the para...
Paulettepauley asked 20/6, 2023 at 7:7

3

Solved

I am trying to view nested annotate (aggregated/calculated) fields in Django REST Framework serializers. This would allow to work more cleanly with annotated fields. This post is similar to Aggrega...
Inquire asked 6/10, 2015 at 8:9

6

I'm having trouble testing a ViewSet: class ViewSetTest(TestCase): def test_view_set(self): factory = APIRequestFactory() view = CatViewSet.as_view() cat = Cat(name="bob") cat.save() reques...
Brussels asked 15/4, 2014 at 0:38

2

i am trying to add custom permissions in my Django app using Django rest framework. i created an API n tested it in postman it works fine for authenticated user. however it doesnt display details w...
Detonator asked 20/7, 2018 at 6:55

3

Solved

I'm using Memcached as backend to my django app. This code works fine in normal django query: def get_myobj(): cache_key = 'mykey' result = cache.get(cache_key, None) if not result: result = P...
Carnivore asked 12/7, 2016 at 4:25

10

Solved

I am new to DRF. I read the API docs, maybe it is obvious but I couldn't find a handy way to do it. I have an Answer object which has one-to-one relationship with a Question. On the frontend I used...
Cowans asked 15/6, 2016 at 10:48

5

Solved

I am trying to create an authentication API for a flutter app that will log users in with a google authentication signup/login form. I followed this tutorial to achieve this. So far so good, except...

2

Solved

I am completely new to python as well as to Django. I got a sample Django Rest project. When I run: python manage.py makemigrations I get the error: ImportError: No module named django_extensi...
Condyloid asked 31/5, 2017 at 16:6

3

I'm working on a project and problem is I've already created models with simple ID column but now my requirements are changed and I want to replace ID field (model) with UUID field I just updated m...
Hamrah asked 11/1, 2018 at 4:58

5

Solved

I have a lot of resources and i want to apply the DjangoFilterBackend to all of them. Tried setting in settings.py 'DEFAULT_FILTER_BACKENDS': [ 'rest_framework.filters.DjangoFilterBackend', ] ...
Typewrite asked 30/11, 2014 at 16:33

5

Solved

Is it possible to get the current user in a model serializer? I'd like to do so without having to branch away from generics, as it's an otherwise simple task that must be done. My model: class Ac...
Nutlet asked 14/1, 2015 at 2:16

4

Solved

I'm getting the above error when creating token, here's the code: from rest_framework import generics, permissions from rest_framework.response import Response from knox.models import AuthToken f...
Secessionist asked 13/4, 2019 at 17:58

8

Solved

I'm trying to create an API for my user registration using Django Rest Framework. I created a serializer by following the step from the api-guide class CreateUserSerializer(serializers.ModelSerial...
Weatherworn asked 26/12, 2016 at 14:15

7

I'm trying to import and use ultralytics library in my Django rest framework project, I use poetry as my dependency manager, I installed ultralytics using poetry add ultralytics and on trying to im...
Uziel asked 24/5, 2023 at 21:9

5

Solved

Situation While working with validation in the Django REST Framework's ModelSerializer, I have noticed that the Meta.model fields are always validated, even when it does not necessarily make sense...
Thanatos asked 21/12, 2014 at 16:52

4

Solved

I'm trying to cache some of my DRF api calls in a CDN. I need the following headers Cache-Control:public, max-age=XXXX This is pretty easy when you're using traditional django templating, you just...
Mchugh asked 29/10, 2016 at 16:1

8

Solved

Django REST Framework has an excellent piece of documentation about permissions. I've been able to use pre-made permission classes and also built my own. However, there are some API methods in whi...
Januarius asked 29/4, 2015 at 6:52

2

https://tauri.localhost' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response. I have added https:/...
Comprehensible asked 21/6, 2023 at 9:24

2

Solved

I have a serializer which contains a URL field, By default, if there is a field named as URL then the value of this field is added in the HEADER option as LOCATION, I don't want to do this, and wou...
Salome asked 9/8, 2021 at 4:52

3

Solved

I read in a post that it is ideal to put that it is a good standard to include a Location header that points to the URL of the new resource (newly created via POST). My problem is I do not know how...
Crosspiece asked 23/7, 2016 at 10:58

© 2022 - 2024 — McMap. All rights reserved.