tastypie

How can I pass a detail object to custom authorization in tastypie?

邮差的信 提交于 2019-12-14 00:27:04
问题 How can I access the detail endpoint object being accessed in the request during a tastypie authorization? I noticed that one of the overridden methods in the docs has an object parameter -- how can I set this? 回答1: In branch perms, https://github.com/toastdriven/django-tastypie/blob/perms/tastypie/authorization.py Class Authorization has a set of methods for example: def read_detail(self, object_list, bundle): """ Returns either ``True`` if the user is allowed to read the object in question

Django- Get values from Tastypie-Bundle

橙三吉。 提交于 2019-12-13 21:34:47
问题 I'm making a RESTful API using Django-Tastypie. I need to get(retrieve) the values POSTed/send through my form. Here is my code. class InstallationResource(ModelResource): class Meta: queryset = Installation.objects.all() resource_name = 'installation' class ApiActionsResource(ModelResource): installation_id = fields.ForeignKey(InstallationResource, 'installation111') class Meta: queryset = Controller.objects.all() resource_name = 'actions' allowed_methods = ['post'] fields = ['installation

Django AJAX Request Fails To Send

我的未来我决定 提交于 2019-12-13 21:26:05
问题 I'm trying to make an AJAX POST request to create a new object. I have a Tastypie API that I would like to handle the request. Here is my code. JS: <script> $(document).ready(function (event) { $('#newpersonalitem').submit(function (event) { event.preventDefault(); var data = {name: $('#name').val()}; $.ajax({ url: 'http://162.216.18.30:8000/api/v1/personalitem/' type: 'POST', contentType: 'application/json', data: data, dataType: 'json', processData: false, success: function (data) {

Django Tastypie Many to Many (self) field update using a PATCH or PUT request?

旧时模样 提交于 2019-12-13 17:28:16
问题 I have this model: class UserSub(models.Model): user = models.OneToOneField(User, related_name='userSub') amigos = models.ManyToManyField('self', null=True) title = models.TextField() Imported Django User Model. And the following resources: class UserResource(ModelResource): usersub = fields.OneToOneField('test.api.UserSubResource', attribute = 'personal', related_name='user', full=True, null=True) class Meta: object_class = User fields = ['username', 'first_name', 'last_name', 'password',

Django Tastypie Deserializing Multipart/Form-Data To Upload File

陌路散爱 提交于 2019-12-13 16:52:34
问题 I am trying to upload files via a Multipart/Form-Data form and Tastypie API and am running into some issues: My Model: class Client(models.Model): account = models.ForeignKey(Account) client_image = models.FileField(upload_to=client_image_path, default="/assets/img/default-user-image.png", blank=True, null=True) client_image_thumb = models.FileField(upload_to=client_image_thumb_path, default="/assets/img/default-user-image.png", blank=True, null=True) I am using a custom deserialize method as

Django database error: missing table social_auth_usersocialauth when social_auth is not installed

瘦欲@ 提交于 2019-12-13 12:07:56
问题 I'm trying to deal with a very puzzling error in a Django app. When DEBUG=False, trying to delete a user (via user.delete() ) gives this database error: DatabaseError: relation "social_auth_usersocialauth" does not exist LINE 1: ...", "social_auth_usersocialauth"."extra_data" FROM "social_au... However, I do not have social_auth or anything by a similar name in INSTALLED_APPS, nor are there any such tables in my database, nor does any of my code reference anything of the sort (I ran a text

Import Django settings from external script

女生的网名这么多〃 提交于 2019-12-13 07:09:42
问题 I have a python script within my Django project designed to run seperate from the Django app. I want to use the settings.py on my Django App how can I do that. When I try to import from django.conf import settings i get ImportError: No module named DjangoTastypie.settings My project Structure I am running using eclipse-> Run as python 回答1: Read https://docs.djangoproject.com/en/1.9/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage So you basically will need to put

Accessing comments on an object via reverse relationship with Tastypie

≯℡__Kan透↙ 提交于 2019-12-13 05:14:15
问题 I'm building an API using Tastypie with Django and I've run into a bit of an issue. I have a model called a Moment (basically a blog post, with a title and body text), and I want to be able to attach comments to it and retrieve them via the API. I'm using django.contrib.comments with Django 1.6.5 and Tastypie 0.11.1. Now, according to the Tastypie documentation, this should be straightforward. What I've implemented is pretty close to that. This is my models.py : class Moment(models.Model): ""

Django TastyPie Patch to a Many-to-Many

♀尐吖头ヾ 提交于 2019-12-13 04:22:09
问题 I'm trying to use TastyPie Patch to a many-to-many, but I get this error: "error_message": "Tastypie requires a Python-style path () to lazy load related resources. Only given 'SchemeResource'.", Why? The patch I'm making: /participant/84 POST: {"email":"test@test.com", "schemes":{"id":"12", "schemes"}} Resource: class ParticipantResource(ModelResource): schemes = fields.ToManyField('SchemeResource', attribute='schemes', full=True, null=True) class Meta: queryset = Participant.objects.all()

Tastypie foreign key relationship throwing error

倖福魔咒の 提交于 2019-12-13 03:24:34
问题 I have a Photo application setup using tasty pie. I tried adding functionality to let users like a photo, using a PhotoLike model and resource. I thought it would be a simple addition, but I have been pulling my hair out for two days now :( I am getting the error below { "error_message": "'dict'objecthasnoattribute'obj'", "traceback": "Traceback(mostrecentcalllast):\n\nFile\"/env/lib/python2.7/site-packages/tastypie/resources.py\",line195,inwrapper\nresponse=callback(request,*args,**kwargs)\n