A lightweight library for Django to help expose an app's functionality as a RESTful web API.
0
votes
0answers
20 views
Django JSON Error - “This field is required”
I have generated the correct json output for my service. I've copied and pasted the restkit output in the browser for the restservice and it works just fine. However, I get
{"questions": ["This ...
0
votes
0answers
12 views
django rest Framework authentications
I have developed an API using django rest framework and have used Token based authentication, Now I have trying to use it from separate project. How I can login using userid and password and get token ...
1
vote
1answer
56 views
How to do an HTTP Options request in AngularJS?
AngularJS' $http service doesn't provide for HTTP Options requests, and I very much would like to have them.
I created a Web API using Django REST framework and I'm trying to leverage all it offers ...
0
votes
0answers
9 views
Dynamically adding field in Django Rest Framework generics.ListAPIView
I have a view that can be called with a longitude and latitude parameters.
When those parameters are set, I want the response to add the distance fields in the serialization.
Here is how I do that:
...
1
vote
1answer
15 views
django-rest-framework document API in OPTIONS
I'm writing my very first REST API (with django-rest-framework).
I'm adding URL parameters to filter the results. My understanding is that these parameters' documentation belongs in the OPTIONS verb. ...
0
votes
0answers
18 views
Upload/Download files using django-restframework gridfs and mongoengine
I'm playing around with django, django rest framework and mongodb (mongoengine). Currently I'm trying to figure out the best way (or at least some kind of best practice way) to upload and download ...
1
vote
0answers
25 views
How to implement a hierarchy of resources (eg. /parents/<id>/children) in Django REST Framework
I couldn't find any information on how to achieve this in the tutorial at the Django REST Framework website and I haven't managed to find it in the documentation, though I'm sure it's there somewhere.
...
0
votes
0answers
12 views
Django-rest-framework timezone aware renderers/parsers
I'm building an app that would serve people located in different places arround the world.
I'm using Django-Rest-Framwork for the communication between the clients and the server.
All DateTime values ...
0
votes
0answers
12 views
Generic View for Rendering JSON and HTML
In ListAPIView, I try to overload the class for rendering HTML and JSON as below. For JSON rendering, it is expected to provide serializer.data for Response to render JSON output. For HTML rendering, ...
2
votes
0answers
20 views
User controlled presentation of data in widgets on a dashboard app - Best Practices?
Consider a very simple dashboard application in Django. It has 2 models:
Page
Widget
Naturally, Page and Widget have a ManyToMany relationship.
Like any good dashboard implementation, the ...
1
vote
1answer
28 views
How can I import the user model in Django and select all of the objects
When I use
from django.conf import settings
in my DjangoRestFramework views,
class UserList(ListCreateAPIView):
queryset = settings.AUTH_USER_MODEL.objects.all()
serializer_class = ...
1
vote
0answers
36 views
How can I define a list field in django rest framework?
Let's say I have a class
class Tags(object):
tags = []
def __init__(self, tags):
self.tags = tags
and a custom list field
class TagsField(serializers.WritableField):
"""
...
1
vote
1answer
23 views
Rest Framework Class Based Views with partial assignments
I'm following the tutorial laid out here to create generic class based views for my API - however, I have run into a small problem. I would like to update the model behind the view partially. I used ...
0
votes
1answer
28 views
Retreiving a Foreign Key value with django-rest-framework serializers
I'm using the django rest framework to create an API.
I have the following models:
class Category(models.Model):
name = models.CharField(max_length=100)
def __unicode__(self):
...
1
vote
1answer
39 views
Include intermediary (through model) in responses in Django Rest Framework
I have a question about dealing with m2m / through models and their presentation in django rest framework. Let's take a classic example:
models.py:
from django.db import models
class ...
1
vote
1answer
42 views
Django REST framework - Serializing and Deserializing a list of primitive types
The task at hand is to use a Serializer to serialize a list of primitive types lets say integers or strings, and then to deserialize this list again. This should be really easy but somehow I cannot ...
0
votes
1answer
35 views
AttributeError with Django REST Framework and MongoEngine
I am trying to use Django and the Django REST Framework together with MongoEngine but it doesn't seem to work for me. I don't know where things go wrong ... perhaps someone can help me out. Here is ...
1
vote
1answer
41 views
Is there a way to specify abstract functions which take in values for __init__
I was not sure how to specify this completely in the title, so please forgive me. Essentially, I want to define a method a get_object() method, like the one described here
...
3
votes
3answers
68 views
Building REST APIs for python
I am building REST APIs for some python code that my team will use internally and may be making it public later. I want to know if anyone used Django REST framework http://django-rest-framework.org/. ...
2
votes
1answer
37 views
Getting mongoengine and django rest framework to play nice
I am wondering how I can get mongoengine and djangoRESTframework to work with each other. Currently, my model is
from mongoengine import *
import datetime
class Blog(Document):
post_id = ...
0
votes
0answers
36 views
Nested URL Patterns in Django REST Framework
I'm trying to go beyond Django REST Frameworks initial flat URL patterns. For example, if I have object types parentobject and childobject where parentobject HAS childobject(s) then the out of the ...
0
votes
1answer
21 views
How to add permissions in Django Rest Framework for specific requests
I am creating a class based api for a documentation app, but I want to add specific permissions to the post and patch definitions in my APIView. For example,
class DocumentList(APIView):
def ...
0
votes
0answers
26 views
Safari not sending Authorization header on sencha app
I am working on a Sencha touch 2 app, and I'm using Django-REST authentication.
Specifically, I'm using TokenAuthentication. The app is working fine on Chrome, but on Safari the Authorization header ...
0
votes
2answers
29 views
How would I create a CBV using django rest framework which will either retrieve a model instance or create a new one?
I have a person model with the fields first_name, last_name and email. I'd like to send these fields to a view that would check the DB for an existing instance. If there is one the ID will be ...
0
votes
1answer
30 views
How to convert unicode original python type
I am posting such data using postman rest client.
{ 'name':"xyz",
'data':[{'age': 0, 'foo': 1}, {'age': 1, 'foo': 1}]
}
I am geting data as unicode so I could not fetch dictionary value ...
3
votes
1answer
83 views
AttributeError: 'user_list' object has no attribute '_ignore_model_permissions'
I'm going through the django REST framework tutorial, except replacing the Snippet model with my own custom User model. However, when I try to test out the API, I keep getting
Traceback (most recent ...
0
votes
1answer
27 views
How can I write a nested serializer that behaves differently when writing or reading?
I am looking for a way to create a nested serializer which will behave differently when writing or reading. In my specific case, I have some models that look like this:
class Frame(models.Model):
...
2
votes
1answer
53 views
Django REST Framework - 405 METHOD NOT ALLOWED using SimpleRouter
I'm using the SimpleRouter tuorial within the docs.
Just to test I've created a temporary Authentication class:
class BackboneBasicAuthentication(authentication.BaseAuthentication):
def ...
1
vote
0answers
89 views
django rest nested relation in post/put
I am new in django rest api developement. I have two models one is category and another is subcategories.
Here is my models
class Category(models.Model):
title = models.Charfield()
...
0
votes
1answer
48 views
Django Rest Framework not saving foreign key for a small number of requests
I am using Django Rest Framework to provide API to a mobile app. I have two models, Order and User. Order has a foreign key relation to User.
For about 1% or so of all my order objects, the User ...
0
votes
0answers
57 views
CSRF error when using rest_framework.authtoken.views.obtain._auth_token
I am calling obtain.auth_token from urls as follows
url(r'^api-token/','rest_framework.authtoken.views.obtain_auth_token')
I get back
{
detail: "CSRF Failed: CSRF token missing or incorrect."
}
...
0
votes
0answers
20 views
Rest framework django fix url when using with json
i have a basic ModelViewSet setup in my rest framework, as following
class UserSerializer(serializers.ModelSerializer):
"""
"""
class Meta:
model = User
fields = ...
2
votes
1answer
29 views
ModelSerializer using model property
I'm trying to serialize a model containing a property field that I also want to serialize.
models.py:
class MyModel(models.Model):
name = models.CharField(max_length=100)
slug = ...
0
votes
1answer
19 views
django rest framework choosing between two possible views for hyperlinked field
So I have two different API views on to User, one that superusers can use, and one that normal users can use.
At the moment, the problem is that my hyperlinks are going to auth_users view by default, ...
0
votes
0answers
24 views
Serialize contents of filefield using Django Rest Framework
I am using django rest framework and need help with the following:
I have a DB model, Card, which has 3 fields: "pk", "uuid" (defaults to uuid1 string), and "content" which is a filefield pointing to ...
0
votes
0answers
23 views
Serialize M2M relation with through table
I have the following models:
class Packing(models.Model):
name = models.CharField(max_length=100)
size = models.CharField(max_length=50,blank=True)
class Product(models.Model):
name = ...
1
vote
1answer
17 views
Correctly instantiating a DRF ModelField
I am trying to use ModelField to serialize a JSONField. I am not quite sure what is the expected thing to be passed into 'model_field' kwarg. Passing the class name doesn't cut it since the ModelField ...
0
votes
1answer
29 views
import error using djangorestframework with django-nonrel
I'm working on a Django-nonrel project using Django-rest-framework and I've run into the following error after following the instructions in the Token Authorization section of their Authorization API ...
1
vote
0answers
53 views
how to register users in django-rest-framework?
I'm coding a REST API with django-rest-framework, the API will be the backend of a social mobile app. After follow the tutorial I can serialise all my models and I be able to create new resources and ...
0
votes
0answers
28 views
Update Related Field
I've been pulling my hair out trying to figure out how to do the below with django rest framework. I've got userprofile model that has a foreignkey tying back to the user table:
class ...
2
votes
1answer
33 views
Filtering using serializers.ModelSerializer
I would like to use a filter on class that is used to serialize a queryset. I constructed the following filter:
# define a filterset
class commentFilter(django_filters.FilterSet):
class ...
0
votes
1answer
90 views
How can I apply a filter to a nested resource in Django REST framework?
In my app I have the following models:
class Zone(models.Model):
name = models.SlugField()
class ZonePermission(models.Model):
zone = models.ForeignKey('Zone')
user = ...
1
vote
1answer
73 views
Django Rest Framework - two models in the same api call
i'm trying to do a thing with Django Rest Framework.
I've a class that is linked to another class via foreign key.
now, i want to create an API call create both the models.
class A(models.Model):
...
1
vote
0answers
37 views
Serializing a list of object as dictionnary in DjangoRestFramework
Using django & django-rest-framework, I have the following model (this is simplified but it's all there):
class Device(Model):
#stuff
class DeviceInformation(Model):
device = ...
0
votes
0answers
49 views
How to write a django-rest-framework serializer / field to merge data from generic relations?
I have objects with a generic relation pointing to various other objects, and I need them to be merged (inlined) so the serialized objects look like one whole objects.
E.G:
class ...
1
vote
1answer
57 views
Filtering ListAPIView in django-rest-framework
I'm using ListAPIView, but I can't filter the results. My code is:
class UserPostReadView(generics.ListAPIView):
serializer_class = PostSerializer
model = serializer_class.Meta.model
...
0
votes
0answers
31 views
How to render html page use Django REST framework
How to render html page use Django REST framework.
Maybe there is another library with similar functionality?
0
votes
1answer
54 views
Removing fields from django-rest-framework view
is there any way to show only a list of fields or excluding some of them when using django-rest-framework?
Here's my app/views.py:
from rest_framework.generics import ListAPIView
from .models import ...
0
votes
1answer
101 views
'WSGIRequest' object has no attribute 'successful_authenticator'
I've made an authentication class just like that :
Token Authentication for RESTful API: should the token be periodically changed?
restapi/settings.py
REST_FRAMEWORK = {
...
1
vote
2answers
312 views
angular, django and csrf
from http://docs.angularjs.org/api/ng.$http , it says we should set default headers to include the token, so i am following it.
my code goes something like this
var myapp = angular.module('myapp', ...