Skip to content
Advertisement

Tag: django-rest-framework

django-rest-framwork got AttributeError when attempting to get a value for field

I want to get all prodcut table values with join product_ratings table. I did somthing like this but this code give me AttributeError. So I did product_ratings = ProductRatingSerializer(many=True) in product serializer and used this value in the field, but it’s not working: The full error message: view : its serializer classes: related model class : Answer Default reverse lookup

Getting an Assertion error in my django application(1.8.4)

I am getting an exception value on running application : (“Creating a ModelSerializer without either the ‘fields’ attribute or the ‘exclude’ attribute has been deprecated since 3.3.0, and is now disallowed. Add an explicit fields = ‘__all__’ to the StockSerializer serializer.”,) Answer As the error message says, the required attribute is fields with an ‘s’, not field.

Django Rest Framework JWT Unit Test

I am using DRF with the JWT package for authentication. Now, I’m trying to write a unit test that authenticates itself with a JWT token. No matter how I try it, I can’t get the test API client to authenticate itself via JWT. If I do the same with an API client (in my case, Postman), everything works. This is

Django Rest Framework – AssertionError Fix your URL conf, or set the `.lookup_field` attribute on the view correctly

I’m trying to return a single object specific to a user (not a queryset), without having to specify an identifier/pk within the requested URL. Each user has an organisation FK. i.e. http://website/organisation and not http://website/organisation/1 I’m receiving the following error, since it’s expecting this identifier: AssertionError: Expected view OrganisationDetail to be called with a URL keyword argument named “user__organisation_id”. Fix

How can I serialize a queryset from an unrelated model as a nested serializer?

I’m trying to add a nested serializer to an existing serializer based on some criteria of the parent model, not a foreign key. The use case is to return a ‘Research’ object with an array of ‘ResearchTemplate’ objects that are identified by filtering on a Postgres ArrayField. Models class Research(TimeStampedModel): category = models.CharField(max_length=100, choices=RESEARCH_TEMPLATE_CATEGORIES, default=’quote’) body = models.CharField(max_length=1000, blank=True, default=”)

how to parse json array in django

I am new in django rest api framework and using get i am fetching the a json array whose api is this https://api.coursera.org/api/courses.v1?q=search&query=machine+learning and i am not able to parse it.Actually i want to store all the names and send them to .html file .I have used this code but didnot worked for me. Answer This actually has nothing to

Advertisement