I have my model class: and my View: My model only takes in 1 field which is the email. Not sure why I keep getting ‘TypeError: post() takes 1 positional argument but 2 were given’. Answer Your post is a method, so the first parameter is self: It is however quite seldom that one implements a post method itself. Usually
Tag: django-rest-framework
How do I specify a custom lookup field for a DRF action on a viewset?
I would like to specify a custom lookup field on the action (different from the viewset default “pk”), i.e. But the router does not generate the correct urls: yields url: instead of I do not want to change the lookup field for the whole viewset though and have been unsuccessful in finding a way to do this for the action
Django/Wagtail Snippet Serializer in API
I have added wagtail CMS’s blog author in my ‘models.py’ also exposed it in API, but it’s showing like this in API Here’s the models.py code How do I serialize like this show author name, website, image and id? I tried to Serialize the BlogAuthor And here is the API field APIField(“blog_authors”, serializer=AuthorSerializer(many=True)), When I runserver I got this error
Building a REST API using a Python based open source framework and NoSQL backend
I would like to build a REST API using a NoSQL backend with a Python based open source framework to build the API. This API would run in a cloud environment and the goal is for it to be cloud agnostic and have the ability to be deployed anywhere. It must have some abstraction for the backend database technology. I
python manage.py collectstatic error: cannot find rest_framework bootstrap.min.css.map (from book ‘Django for APIs’)
I am reading the book ‘Django for APIs’ from ‘William S. Vincent’ (current edition for Django 4.0) In chapter 4, I cannot run successfully the command python manage.py collectstatic. I get the following error: I have the exact same settings like in the book in settings.py: I couldn’t find any explanation for it. maybe someone can point me in the
How to Join Subqueries in Django ORM
I’m a beginner Django and I have been stuck on the following problem for a while. The basic thing I would like to achieve is that when client makes a GET list api request with a time period parameter (say 3 months) then the server would return an aggregation of the current 3 months data and also show an extra
DRF – Relate an object to another using views, serializers and foreign key
Basically I have two models with one-to-one relationship. And I want retrieve information from one, when I call the other. My models: So I can just call an POST and create an Customer, that customer will have id, first_name and last_name. For now everything is working. But when I try to call my endpoint to create an CurrentAccount informing my
serializer not being called AttributeError: ‘str’ object has no attribute ‘_meta’
I modified the Auth User by using AbstractUser Class. Registered it in settings. Everything else is working I can create an instance using the User Model BUT The Problem comes during the serialization. My serializer doesn’t throw any error, but any time I try and use the serializer.data I get AttributeError: ‘str’ object has no attribute ‘_meta’. User Model Custom
django: How do i save form in django without the django forms?
I am trying to save a contact form, but i am not using the django form but instead the input field. I am getting the name, email address and message body from the html templates using input field like this <input type=”text” id=”name”> but the form doesn’t get any data from the input field, it seems i am missing something
Use Serializer Method Field in another Method field
In my serializer, I have a method field, that I would want to use in another method field. This will be best explained in code: serializers.py models.py So I want users to see the first step of data analysis and then analyze the same data further. Is that possible? Maybe that is something I shouldn’t do? Answer I would use