tastypie

RESTFUL web services consumed by web and native mobile apps with authentication in python using django framework

浪子不回头ぞ 提交于 2019-12-03 00:29:51
I have to write RESTFUL web-services with authentication in python using django framework which will be consumed by web based clients and mobile native apps (Android and IOS). the simple example would be that user will log in using email and password, he fetches the api key and stores it on the mobile device and then use this api key for consuming further api's instead of giving user credentials again and again. I am thinking of using TASTYPIE or Django piston for writing RESTFUL services but please suggest otherwise if you know any better solution. But my main focus is on the authentication

Connect facebook phonegap login with django allauth

走远了吗. 提交于 2019-12-02 20:56:50
I'm building up an app that should allow the user to sign up / sign in with Facebook and then he should be able to login (always via Facebook ) to the "main" website To be honest it's a bit more complicated than this. That's because I'm using django-tastypie and django-allauth in the main website to allow sign up, login, and browsing of our API Basically I want to make the mobile app user browse the tastypie API (accessible only if logged and if you're an user in the main website) and grant him the rights to add rows (like orders) Here's what I have A phonegap app with a working Facebook login

Exposing model method with Tastypie

半腔热情 提交于 2019-12-02 19:35:07
I am currently working on implementing an API into my Django project and Tastypie seemed like it would be most suitable. What I can't seem to work out is how to expose a function within my model using Tastypie. For example, I have this model: class game(models.Model): id = models.AutoField("ID", primary_key=True, editable=False) ip_address = models.OneToOneField(IPAddress, verbose_name="IP Address") port = models.CharField("Port", max_length=5) name = models.CharField("Game Name", max_length=100) ram = models.IntegerField("RAM (mb)", max_length=10) node = models.ForeignKey(node) user = models

Django : DRF Token based Authentication VS JSON Web Token

瘦欲@ 提交于 2019-12-02 19:16:21
I am building a real world application where users will access the app primarily from Android, iOS devices as well as Desktops. From my elementary research, I have realized that token based authentication mechanism is more better and elegant for client-server models as compared to session based authentication. In Django, I have found two popular ways to do this - http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication http://getblimp.github.io/django-rest-framework-jwt/ From what I understood, option 2] is an extension of 1] except that the Token is in the form of

How to make sure that my AJAX requests are originating from the same server in Python

独自空忆成欢 提交于 2019-12-02 17:34:22
I have already asked a question about IP Authentication here: TastyPie Authentication from the same server However, I need something more! An IP address could be very easily spoofed. Scenario: My API (TastyPie) and Client App (in javascript) are on the same server/site/domain. My users don't login. I want to consume my API in my javascript client side. Question: How can I make sure (authentication) that my AJAX requests are originating from the same server ? I'm using Tatypie. I need to authentication that the requests from the client are being made on the same server/domain etc. I cannot use

How to expose a property (virtual field) on a Django Model as a field in a TastyPie ModelResource

我的梦境 提交于 2019-12-02 16:39:27
I have a property in a Django Model that I'd like to expose via a TastyPie ModelResource. My Model is class UserProfile(models.Model): _genderChoices = ((u"M", u"Male"), (u"F", u"Female")) user = Models.OneToOneField(User, editable=False) gender = models.CharField(max_length=2, choices = _genderChoices) def _get_full_name(self): return "%s %s" % (self.user.first_name, self.user.last_name) fullName = property(_get_full_name) My ModelResource is class UserProfileResource(ModelResource): class Meta: queryset = models.UserProfile.objects.all() authorization = DjangoAuthorization() fields = [

reverse lookup by ForeignKey in Tastypie

痞子三分冷 提交于 2019-12-02 14:54:58
问题 I have a post model and a comment model that holds the comments that were made for a particular post. class Post(models.Model): body = models.TextField() user = models.ForeignKey(User) class Comment(models.Model): post = models.ForeignKey(Post) date = models.DateTimeField(auto_now_add=True) comment = models.TextField() comment_user = models.ForeignKey(User) Now I want my Post resource to include URI to all the comments attached to a particular post. I do know I can use fields.ForeignKey to

Tastypie return data from DELETE requests?

旧巷老猫 提交于 2019-12-02 13:35:11
问题 I have a simple resource that I would like perform a DELETE. On success I would like to get the ID of the object that was deleted. As per the docs, always_return_data - Specifies all HTTP methods (except DELETE) should return a serialized form of the data. http://django-tastypie.readthedocs.org/en/latest/resources.html#always-return-data class SimpleResource(resources.MongoEngineResource): class Meta: queryset = Simple.objects.all() resource_name = 'simple' allowed_methods = ('get', 'put',

django-tastypie: Cannot access bundle.request in dehydrate(self,bundle)

梦想与她 提交于 2019-12-02 12:35:09
问题 I found someone with the same problem, but the solation for him doesn't work with me: see Django-Tastypie: How Do You Access (Http)request object in the Bundle? I Am trying to apply the workaround suggested in: Django tastypie: Resource show different in detailed request as in list request resulting in this code in my resources file (api.py): class LocationResource(ModelResource): locationtype = fields.ForeignKey(LocationTypeResource, 'locationtype', full=False) class Meta: queryset =

django-tastypie: Cannot access bundle.request in dehydrate(self,bundle)

隐身守侯 提交于 2019-12-02 06:05:18
I found someone with the same problem, but the solation for him doesn't work with me: see Django-Tastypie: How Do You Access (Http)request object in the Bundle? I Am trying to apply the workaround suggested in: Django tastypie: Resource show different in detailed request as in list request resulting in this code in my resources file (api.py): class LocationResource(ModelResource): locationtype = fields.ForeignKey(LocationTypeResource, 'locationtype', full=False) class Meta: queryset = Location.objects.all() resource_name = 'location' excludes = ['public_anonymous', 'public_authorized','x','y',