Django relies on frame authentication

I would like create authentication in Django. I'm trying to do everything according to this. Unfortunately, at this moment I have two problems. Firstly, when I try to add from rest_framework.authtoken import views I have conflict with from companies

Django Rest Framework - If the condition is ignored

I created a end-point that returns a PDF. I have an condition to check if the asset exists, but that condition is always ignored. If the condition doesn't exist the end-point returns 500 not 404 as I want urls: url(r'^report/asset/(?P<pk>[0-9]+)$',

Django REST Framework serializer with different models

I have three different models that I want to gather in a feed type page. They do all contain different types of things but for simplicity, the models are the same in this instance. class ObjectA(models.Model): text = models.TextField() pub_date = mod

The Django serializer calls a function

I have: class ProfileSerializer(serializers.ModelSerializer): relevence = ?? The thing is I want to call relevance as a separate function. I do not want to write it as a serializer method field nor under a model, can it be done?Ok. do it like class P

ModelViewSet - Hide fields selectively?

I have an Instructor model, which has a many to many field to a Client model. (Instructor.clients) The model: class InstructorProfile(models.Model): '''Instructor specific profile attributes ''' # Fields office_number = models.CharField(max_length=30

Django image download rest frame and test client

I'm trying to upload a picture with rest framework and to test it with the django test client. It almost works, however when I save the file I have this on the top of my file: --BoUnDaRyStRiNg Content-Disposition: form-data; name="plop.png" If I

django remains back result that combines filters

I'm new to Django rest and i'm trying to return response that have to use two query sets: The first one is for the specific project and the second one is only for specific users inside this project: class ProjectFiltersSerializer(seria

MinValueValidator does not work on DecimalField in Django

I have an API developed with Django and Django Rest Framework. I've got a model with a DecimalField which should store values of at least one. Therefore, I've defined the field in the following way: goal = models.DecimalField(decimal_places=2, max_di

How can I set the default value in serializers?

I have these serializers: >---id = serializers.IntegerField() >---name = serializers.CharField() >---age = serializers.IntegerField() Now, I give the serializers this data: {'id': 1, 'name': 'cc'} I don't give a value for age. how can I set a def

DjangoRestFramework - Omit null fields when serializing objects

This is my Model: class Post(models.Model): user = models.ForeignKey(User) post = models.CharField(max_length=400) country = models.ForeignKey(Country, blank=True, null=True) and this is my serializer: class PostSerializer(serializers.ModelSerializer

Unable to read request headers on the deployment server

I'm working in a django project and I'm building an Api using Django Rest Framework for let users get some data on their mobile devices. I'm sending some extra paramenters in the headers dictionary for each request, not only the auth token. I'm testi

Advance serialization in DRF

I'm trying to achieve something with Django Rest Framework. The idea is for a model to have several fields of several types in read-only, and have the same fields writable for the user that would take precedence when serving the data. Since this shou

Configuring the Content Range for Django Rest Paging

6.30.15 - HOW CAN I MAKE THIS QUESTION BETTER AND MORE HELPFUL TO OTHERS? FEEDBACK WOULD BE HELPFUL. THANKS! I need to send a content-range header to a dojo/dgrid request: I cannot find any examples of HOW to do this. I'm not exactly sure where this

Swagger does not work with the Django BaseSerializer object

I'm using django-rest-swagger to document and test an API and it has been working very well up to now but the following error has occured: AttributeError at /docs/api-docs/app 'PeriodSerializer' object has no attribute 'get_fields' 'PeriodSerializer'

Django REST Framework APIClient sends None as 'None'

In my tests, I send mock data of models that I've passed through the serializer. The looks something like this { "field": None } However, the data that my API receives is formatted like { "field": "None" } whi

Django Rest Sets a new value on django view on Post

My form will post data to db. I want to add one filed as hidden in view and it should generate a key as random. my post function is def post(self, request, format=None):['code'] = id_generator() data = serializer = registrat

Django Rest Framework with ChoiceField

I have a few fields in my user model that are choice fields and am trying to figure out how to best implement that into Django Rest Framework. Below is some simplified code to show what I'm doing. # class User(AbstractUser): GENDER_CHOICES

django-rest-framework - autogenerate form in the navigable API?

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 ModelForms. This would allow us to more easily test in