Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
66 views

I have a social network project for users to share their recipes. The Recipe objects managed by a ViewSet, which has Serializer, where create and update recipes operations defined, via POST and PATCH ...
user30835942's user avatar
0 votes
2 answers
136 views

I am using Django with rest framework. Sign Up works fine, but when I log in, after passing the email and password to the backend, the authenticate() returns None even if the credentials are right. I ...
user23033721's user avatar
0 votes
0 answers
76 views

I am trying to combine multiple serializers into a single API call, and as a result, I am using viewsets.ViewSet. I am aware that viewsets.ModelViewSet automatically generates the routes, but with ...
PhilM's user avatar
  • 437
0 votes
1 answer
84 views

I have two Blog API's in Django Rest Framework. One uses Django's default User model whilst the other uses a CustomUser. Authentication works well in both cases. I have similar serializers, viewsets ...
Uchenna Adubasim's user avatar
1 vote
0 answers
58 views

I have ModelViewSet view in django rest framework project. I am trying to filter documents that are not live, I mean are not on main view. To filter I am using params: http://localhost:8000/documents?...
user25455142's user avatar
1 vote
2 answers
61 views

I'm trying to overwrite the response that is sended by django when create a new object. I need to return only the primary key of the created object instead the whole object. The function that I'm ...
Step's user avatar
  • 149
0 votes
1 answer
38 views

I have a Business model and Order model. Businesses can order furniture in our website. A user creates an account and makes an order. Since he is a new user, he is not associated to any Business. In ...
Vinay Stark's user avatar
0 votes
2 answers
79 views

I am trying to write a login view in django restframe work to authenticate a user into the application but each time I send a request to the server I keep getting this error `{ 'email': ['email ...
kelani darasimi's user avatar
0 votes
1 answer
406 views

I just started learning about DRF. We know that with generics and mixin Django REST Framework makes handling GET, POST, PUT, DELETE etc easy for users. And another feature is ViewSets. It helps us to ...
Mosleh Uddin Asad's user avatar
1 vote
1 answer
327 views

I'm designing an api using python DRF for a merchant profile page. ID should not be required to be passed into the api. I'm trying to do a simple fetch to get one object to return as a result and I ...
henry's user avatar
  • 31
1 vote
1 answer
38 views

I am hitting a KeyError for 'children' when I run this create() function: class TaskViewSet(ModelViewSet): queryset = Task.objects.all() serializer_class = TaskSerializer def create(self, ...
Adam Starrh's user avatar
  • 6,998
0 votes
1 answer
160 views

I see in a bunch of django code, especially in viewsets, that when serializer is initialized like the following: class UserViewSet(viewsets.ModelViewSet): """ A viewset that ...
bohorqux1996's user avatar
0 votes
1 answer
101 views

Often I wish to use the created/updated object, for say to log it in some history, or use it in an email. E.g.1. CreateAPIView def create(self, request, *args, **kwargs): ret = super()....
run_the_race's user avatar
  • 2,550
0 votes
2 answers
60 views

I am trying to create a CustomUserViewset, and add a login_user api to it. The problem is that although I set the permission_classes to AllowAny, still when calling the login_user api, it says: {"...
Vahid's user avatar
  • 417
1 vote
0 answers
209 views

I have a Django REST framework viewset with multiple actions such as list, create, and more. When I send a GET request, I noticed that some actions are executed multiple times, and the action is ...
Hamidreza Farzin's user avatar
0 votes
1 answer
96 views

Expanding on the Django REST Framework tutorial, I have switched to TemplateHTMLRenderer to work with HTML. class SnippetViewSet(viewsets.ModelViewSet): queryset = Snippet.objects.all() ...
henrikstroem's user avatar
  • 3,120
0 votes
1 answer
193 views

Creating my first CRUD in Django Rest framework this error keeps popping up. Does anyone know how to fix?? Object of type CharField is not JSON serializable models: class Pessoa(models.Model): id =...
caiiohenryk's user avatar
0 votes
1 answer
79 views

I'm working on Django project with Django Rest Framework. I have a model called Server and I want to filter the queryset by the currently authenticated user, but only if "by_user=true" is ...
Adrian Phoenix's user avatar
1 vote
1 answer
214 views

Models: class GradePolicy(models.Model): name = models.CharField(max_length=30) minScore = models.DecimalField(default=0, max_digits=4, decimal_places=1, db_column="minscore") ...
DeltaG's user avatar
  • 778
0 votes
1 answer
66 views

I am facing an issue with querying the Profile model based on the user_id of a Project instance in my Django REST framework project. When attempting to retrieve the profile using the user_id, I ...
apeCode's user avatar
0 votes
1 answer
47 views

I need to show user info in my post as nested json. Models: Profile # Django from django.db import models class Profile(HelperModel): """ User Profile UserProfile provides the ...
Juan Alejandro Carrillo Jaimes's user avatar
1 vote
1 answer
236 views

I have the below in one of my viewset classes: serializer = ResponsesSerializer(data=queryset, many=True) serializer.is_valid(raise_exception=True) validated_data = serializer....
TabulaRasa's user avatar
1 vote
0 answers
93 views

I'm working with Django REST Framework and I want to reuse a ViewSet in two places, but to do that I need to pass some information to the ViewSet class. This is what my urls.py file currently looks ...
Kevin Renskers's user avatar
0 votes
0 answers
144 views

I have a class viewset that only performs the retrieve action. I have a challenge trying to access the endpoint if a retrieve action is not included in the viewset. The URL for this endpoint takes in ...
Barioder's user avatar
0 votes
1 answer
106 views

I created a ViewSet, in which I need to use in two URL Patterns, one is for getting the list of items and other is for getting the detail of single item. The problem is, when I pass {"get": &...
Khubaib Khawar's user avatar
1 vote
0 answers
39 views

My Models class LessonPlan(models.Model): planner=models.ForeignKey('LessonPlanner', on_delete=models.CASCADE) title=models.CharField(max_length=100, null=True, blank=True) details=models.TextField(...
Neplox Null's user avatar
1 vote
1 answer
192 views

I'm looking for some advice on how to correctly use my DRF API I have built, specifically the PATCH method at present. I am trying to formulate a script to patch the quantity of a Product / Cart Item ...
David Henson's user avatar
0 votes
1 answer
61 views

Right now I have a large viewset class (~1300 lines). The reason for this is, I had to add a lot of @action decorators to acheive my goal. But I can feel that this is taking a lot of my time in ...
Chandra Kiran Guntur's user avatar
1 vote
1 answer
187 views

Pardon me, I'm developing an app using Django REST Framework and when I try to update an user this happen It throw me this error: centros = validated_data.pop('centros') KeyError: 'centros' I'll share ...
Angel Daniel Ascanio Salazar's user avatar
-2 votes
1 answer
460 views

hlo, I have deployed a Django rest app in production. When I call a list API there is a pagination, and I am getting localhost for next page URL. I am using GenericViewSet and LimitOffsetPagination ...
Krishna Bhandari's user avatar
0 votes
0 answers
31 views

ModelA ------ id atr_a atr_b atr_c is_active ModelB ------ id atr_d atr_e modelA_id Without modifying either model, I need to include ModelB data in my ModelA ViewSet. I am not sure how this should ...
user3533755's user avatar
1 vote
1 answer
142 views

I have the following view: class CampaignUpdate(generics.RetrieveUpdateAPIView): queryset = Campaign.objects.all() serializer_class = CampaignSerializer permission_classes = [...
snake_case's user avatar
0 votes
1 answer
31 views

I need to return via rest_framework a users's detail In my views.py i have UserViewSet class with class UserViewSet(viewsets.ModelViewSet): queryset = User.objects.all() serializer_class = ...
aleksander's user avatar
1 vote
1 answer
1k views

Both decorators appear to simply create a route for you. But what would be the practical difference (if any)? In the documentation, it is not clear. I even created two routes the same way and there ...
Joao Albuquerque's user avatar
0 votes
0 answers
653 views

I want to override CreateModelMixin with my own class which derived from ModelViewSet this is the class i want to override class CreateModelMixin: """ Create a model instance. ...
BoazBitt's user avatar
0 votes
1 answer
167 views

SerializerClass: class VacancySerializer(serializers.ModelSerializer): organization_small_name = serializers.CharField(source='organization.short_name', read_only=True) class Meta: ...
kims9's user avatar
  • 65
0 votes
1 answer
81 views

I am trying to count the number of users in my event name field. But I am facing problems in django-rest-framework filtering. I tried different logics, but I cannot count. I got the count when I hard ...
Rishabh Sharma's user avatar
0 votes
1 answer
477 views

I have a User Model Viewset that adds users to my Django Rest Framework application (VueJS -> DRF -> PostGres). I have another ModelViewSet for an activity log that has entries when users get ...
Bring Coffee Bring Beer's user avatar
0 votes
1 answer
204 views

im building a project with DRF and im trying to understand how the modelviewset is working, im sending a url like this: localhost/do_somthing/object_id/ and route it with : router.register('...
ShTurj's user avatar
  • 51
-1 votes
1 answer
166 views

i want to build a ModelViewSet class that recive an id from url for instance localhost/id and based on that id i can either show the object with matching id or delete the object but im having ...
Lin's user avatar
  • 11
1 vote
1 answer
150 views

class Product_List(viewsets.ModelViewSet): # >>> List of products & add product to cart permission_classes = [IsAuthenticated, ] queryset = Item.objects.all() ...
Naga Rajan's user avatar
1 vote
1 answer
1k views

Suppose that I have a Viewset named UserViewset, and I have assigned IsAuthenticated permission to UserViewset Viewset. Now, I want to create a normal method (not an action method), and I want to ...
Khubaib Khawar's user avatar
0 votes
1 answer
739 views

The DRF helps you make a simple API that exposes an endpoint for listings of an object and the details for a specific object. My viewset looks like this: class UserViewSet(ModelViewSet): ...
zsega's user avatar
  • 181
2 votes
2 answers
367 views

In my views, queryset is returning all the users when I want it to be only returning the user that is currently logged. I have a get self method which has the serializer set to the user but it is not ...
Jabba the Hutt's user avatar
0 votes
1 answer
1k views

My user model has a Many to one relationship to a Clothes model and inside my User viewset I created an extra action to list the Clothes instances in relation to a specific user @action(detail=True, ...
Pefori's user avatar
  • 39
0 votes
1 answer
117 views

I have a ModelViewSet and I am using ModelSerializer. I am also using Pagination that is from django.core. My views code snippet that works: page_number = request.data.get("page") data = ...
Lax_Sam's user avatar
  • 1,139
0 votes
1 answer
41 views

Not sure of the reason but maybe I have passed in a wrong way request to the context in views.py, In views.py where post method 'tag' input field is missing class Dot(models.Model): user =...
kubaSpolsky's user avatar
3 votes
2 answers
4k views

I would like to specify a custom lookup field on the action (different from the viewset default "pk"), i.e. @action( methods=["GET"], detail=True, url_name=&...
nefrob's user avatar
  • 150
0 votes
0 answers
92 views

I am using django 4.1 I have a product model class Product(models.Model): product_id = models.CharField( blank=False, null=False, max_length=50, verbose_name="...
Menna Magdy's user avatar
1 vote
1 answer
396 views

I'm learning DRF and I've been stuck on this for a few days. I'm trying to create an endpoint that receives a date range .The response should return a report with the monthly sales distribution for ...
Vasko Shelyavski's user avatar

1
2 3 4 5
8