tastypie

Django-Tasypie image upload example with JQuery

試著忘記壹切 提交于 2019-12-06 13:49:18
问题 I'm looking for a way to implement client side file (image) upload from jquery to Django-Tastypie. So far server side seems correct testing with CURL: I found this post helpfull Django-tastypie: Any example on file upload in POST? EDIT : This is what i did with curl -> in api.py : class MultipartResource(object): def deserialize(self, request, data, format=None): if not format: format = request.META.get('CONTENT_TYPE', 'application/json') if format == 'application/x-www-form-urlencoded':

How do I set the authorization header for tastypie?

醉酒当歌 提交于 2019-12-06 13:30:10
When passing values as parameters in the request it works: curl "http://localhost:8080/wordgame/api/v1/rounds/?username=test_user&api_key=12345678907a9cb56b7290223165e0a7c23623df&format=json" However, it does not work when I try to pass the values in as headers. This results in a 401: curl -H "Authorization: ApiKey test_user:12345678907a9cb56b7290223165e0a7c23623df" -H "Accept: application/json" http://localhost:8080/wordgame/api/v1/rounds/ I am using Tastypie ApiKeyAuthentication Your header looks correct assuming the username/key are right.. Try the version from the github master branch, the

Significant overhead on Django apache vs. built-in dev server

笑着哭i 提交于 2019-12-06 09:04:48
I'm running Django/Tastypie on a soon-to-be production environment, however I am noticing significant overhead using Apache vs. using the built-in dev server. Apache is MUCH slower. Here are non-scientific bandwidth tests using ab: Apache: $ ab -n 100 -c 50 https://www.mydomain.com/api/v1/clock/?format=json This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking www.mydomain.com (be patient).....done Server Software: Apache/2.2.22 Server

In django-tastypie, can choices be displayed in schema?

你。 提交于 2019-12-06 08:42:53
问题 I am trying to figure out whether I can represent model field choices to clients consuming a tastypie API. I have a django (1.4.1) application for which I am implementing a django-tastypie (0.9.11) API. I have a Model and ModelResource similar to the following: class SomeModel(models.Model): QUEUED, IN_PROCESS, COMPLETE = range(3) STATUS_CHOICES = ( (QUEUED, 'Queued'), (IN_PROCESS, 'In Process'), (COMPLETE, 'Complete'), ) name = models.CharFIeld(max_length=50) status = models.IntegerField

PUT request to django tastypie resource not working

可紊 提交于 2019-12-06 05:57:48
问题 i'm trying to do a put request to my django tastypie resource in order to update user info. Up to now, i can make post request but put is not working. In my api.py i have this: class UserResource(ModelResource): class Meta: queryset = User.objects.all() resource_name = 'auth/user' fields = ['username', 'email'] authentication = BasicAuthentication() authorization = DjangoAuthorization() filtering = { "username": ('exact',), } class UserSignUpResource(ModelResource): class Meta: object_class =

Exposing “virtual” field in a tastypie view?

試著忘記壹切 提交于 2019-12-06 05:01:33
问题 I want to create a view using tastypie to expose certain objects of the same type, but with the following two three twists: I need to get the objects using three separate queries; I need to add a field which doesn't exist in the underlying model, and the value of that field depends on which of the queries it came from; and The data will be per-user (so I need to hook in to one of the methods that gets a request). I'm not clear on how to hook into the tastypie lifecycle to accomplish this. The

REST urls with tastypie

旧街凉风 提交于 2019-12-06 03:45:39
问题 I'm using tastypie in my django application and I'm trying to get it to map urls like "/api/booking/2011/01/01" which maps to a Booking model with the specified timestamp in the url. The documentation falls short of telling how to achieve this. 回答1: What you want to do in your Resource is provide an def prepend_urls(self): return [ url(r"^(?P<resource_name>%s)/(?P<year>[\d]{4})/(?P<month>{1,2})/(?<day>[\d]{1,2})%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_list

Tastypie accessing fields from inherited models

此生再无相见时 提交于 2019-12-06 02:36:26
问题 Is it possible to include fields on related models, using tastypie? As per my models below: if I persist one VideoContent and one TextContent instance to the DB, I can then get 2 objects back from my Content resource, however none of the additional fields are available. Is it possible to include fields from related models (in this instance, the video url and the text content) and will that cater for adding more Content types in the future without having to rewrite the Content Resource, or am

Tastypie: How can I fill the resource without database?

我怕爱的太早我们不能终老 提交于 2019-12-06 01:49:54
问题 I want to grab some information from Foursquare , add some fields and return it via django-tastypie. UPDATE: def obj_get_list(self, request=None, **kwargs): near = '' if 'near' in request.GET and request.GET['near']: near = request.GET['near'] if 'q' in request.GET and request.GET['q']: q = request.GET['q'] client = foursquare.Foursquare(client_id=settings.FSQ_CLIENT_ID, client_secret=settings.FSQ_CLIENT_SECRET) a = client.venues.search(params={'query': q, 'near' : near, 'categoryId' :

No module named constants

こ雲淡風輕ζ 提交于 2019-12-06 01:37:29
问题 I want to do sample application with Tastypie framework. I added Tastypie to Installed app and modified urls.py as required, adding from tastypie.api import Api . But when I open http://localhost:8000/api/v1/?format=json , I get the following exception: Exception Value: No module named constants When I run: pip install constants everything looks ok. Python 2.6 (and try on 2.7) Django 1.4 Tastypie 0.10.0 回答1: the problem is in the resources.py file for tastypie. It has the following line: from