I'm new to Djnago / Tastypie and create an API with complex The problem is calculation . The model is similar to:
Class customer (models.Model): '' 'Customer details.' 'Name = model.carfield (max_length = 200, ft = true, empty = true) latitude = model.Diskel field (default = 0, decimal_file = 10, max_digitas = 15, empty = true, zero = true) longitude = model. The decimal time (default = 0, decimal_fill = 10, max_digates = 15, empty = true, zero = true)
is now the task of creating APIs that latitude, longitude , The radius and we will have to calculate all those customers whose latitude and longitude come at the requested point in the given radius.
So far, I have only had the experience of creating simple APIs using TESTIPP. Can anyone suggest a potential resource class for this or any Django / Tastypie Tutorial which can be useful for creating this API?
Both potential approaches in a standard ModelResource
Class MyResource (ModelResource): Class Meta: queryset = MyModel.objects.all () ...
Do all the work of creating an object and add the bundle you return to:
Use parent class to create an object and put it in bundle and then modify the value :
Df OBG_create (self, bundle, request = none, ** quargs): bundle = super (myrassource, self) .boz_create (bundle, request, user = request. User) bundle .bz.value = complex calculation here bundle Obj.save () return bundle
No comments:
Post a Comment