tastypie

PendingDeprecationWarning on django / tastypie

荒凉一梦 提交于 2020-01-05 02:30:12
问题 I am trying to set a pretty straightforward example of a REST service using tastypie, however I am getting a PendingDeprecationWarning. Here is the error message appearing on the browser Request Method: GET Request URL: http://127.0.0.1:8000/myapp/api/myapp_resource Django Version: 1.6.2 Exception Type: PendingDeprecationWarning Exception Value: commit_on_success is deprecated in favor of atomic. Exception Location: /home/pkaramol/Workspace/django-env/lib/python3.3/site-packages/django/db

PendingDeprecationWarning on django / tastypie

心不动则不痛 提交于 2020-01-05 02:30:05
问题 I am trying to set a pretty straightforward example of a REST service using tastypie, however I am getting a PendingDeprecationWarning. Here is the error message appearing on the browser Request Method: GET Request URL: http://127.0.0.1:8000/myapp/api/myapp_resource Django Version: 1.6.2 Exception Type: PendingDeprecationWarning Exception Value: commit_on_success is deprecated in favor of atomic. Exception Location: /home/pkaramol/Workspace/django-env/lib/python3.3/site-packages/django/db

How to filter objects by user id with tastypie?

一曲冷凌霜 提交于 2020-01-04 03:56:10
问题 I have the following user resource: class UserResource(ModelResource): class Meta: queryset = User.objects.all() resource_name = 'user' fields = ['username', 'first_name', 'last_name'] allowed_methods = ['get'] filtering = { 'username': ALL, 'id': ALL, } and the following model resource: class GoalResource(ModelResource): user = fields.ForeignKey(UserResource, 'user') class Meta: #authentication = BasicAuthentication() #authorization = ReadOnlyAuthorization() queryset = Goal.objects.all()

How to filter objects by user id with tastypie?

南楼画角 提交于 2020-01-04 03:56:06
问题 I have the following user resource: class UserResource(ModelResource): class Meta: queryset = User.objects.all() resource_name = 'user' fields = ['username', 'first_name', 'last_name'] allowed_methods = ['get'] filtering = { 'username': ALL, 'id': ALL, } and the following model resource: class GoalResource(ModelResource): user = fields.ForeignKey(UserResource, 'user') class Meta: #authentication = BasicAuthentication() #authorization = ReadOnlyAuthorization() queryset = Goal.objects.all()

Django-Tastypie: How Do You Access (Http)request object in the Bundle?

落花浮王杯 提交于 2020-01-04 03:53:09
问题 I need to access the HttpRequest object in my Resource's dehydrate method. In the docs, it shows that bundle.request is a valid attribute (it's in the resources.html page). When I try to add it to my code, I get an error claiming that Bundle' object has no attribute 'request'. What gives? 回答1: I just had the same problem, but found the correct answer over here: http://groups.google.com/group/django-tastypie/tree/browse_frm/thread/801f44af3f2dbe7b/a36f303380eacf96 it seems django-tasty-pie

Heroku and Django with 405 error

寵の児 提交于 2020-01-03 08:13:52
问题 I am trying to move my django project from an apache setup over to heroku. At this point, everything seems to be working fine except for an issue I am having with using the PATCH Http Method (which I use in conjuction with django-tastypie). I have a piece of middleware that allows this method and it worked on the apache server I had before. Now all I get is a 405 (METHOD_NOT_ALLOWED) error. The common HTTP methods still work (GET, POST, DELETE, POST). I also have read that nginx doesn't

Why does full=true breaks resources behaviour in Django Tastypie?

不想你离开。 提交于 2020-01-03 04:25:12
问题 Using full=true on related fields is very convenient feature to prevent client from doing too many requests to get necessary information. Nevertheless, I really don't understand why the "instructions" in Meta Class are not followed as soon as you use a related field. Here is a simple example: class UserResource(ModelResource): class meta(): queryset = User.objects.all() resource_name = 'users' authorization = NothingAuthorization() # Returns None or [] on GET requests class ClientUserResource

Django tastypie: Resource show different in detailed request as in list request

百般思念 提交于 2020-01-02 03:20:08
问题 I Am just starting with django tastypie, and I Am enthousiastic about it. My question: I Am searching for the same feature as in the admin view: specify for foreignkey fields what to see in the list response of other objects and what in the detailed response. let's say this is my simplyfied model: class Location(models.Model): name = models.CharField(max_length=256, blank=True) longitude = models.FloatField(blank=True, default=0.0) latitude = models.FloatField(blank=True, default=0.0)

Django Tastypie “ToManyField” in “parent” resource seems to break POST to chile resource

 ̄綄美尐妖づ 提交于 2020-01-01 17:36:06
问题 I am using Django 1.4.3 and TastyPie 0.9.11. I have the following two django models: class Event(models.Model): organizer = models.ForeignKey(User, related_name='Organizador') store = models.ForeignKey(Store, related_name='Tienda') name = models.CharField('Titulo', max_length=50) event_time = models.DateTimeField('Fecha y Hora del Evento') creation_date = models.DateTimeField('Fecha de Creación', auto_now_add=True) requires_confirmation = models.BooleanField('Require Confirmación') class Meta

File posting via RESTful api with django and tastypie

狂风中的少年 提交于 2020-01-01 03:07:09
问题 i am creating an RESTful api for a Django website. I am using tastypie for doing it. My problem is i could'nt design how to post images or files via this api. I mean, to create an object on database we are posting data in json format. But how can i put a file inside that json? I found that there is two methods one of them is converting them Base64 format. I don't want to use it because in my tests, image which is 74kb is being 110kb-120kb when converted to Base64. So can anybody explain me