python - how to delete tastypie model resource index -
i'm implementing rest api using django-tastypie. api resource defined follows:
class addressresource(modelresource): class meta: resource_name = 'address' queryset = address.objects.all() always_return_data = true authorization = authorization() serializer = serializer(formats=['json']) validation = validation() i have model address defined as:
class address(models.model): number = models.integerfield() street = models.charfield(max_length=100) city = models.charfield(max_length=100) country = models.charfield(max_length=25) postalcode = models.charfield(max_length=5) i can create address resources posting url http://mydomain.com/api/v1/address/. after address resource creation resource uri /api/v1/address/1/..../api/v1/address/2/....etc
if delete resources directly model database or doing http delete of resource http://mydomain.com/api/v1/address/2/, when new post of resource id of resource uri still incrementing based on last index.
example: have 30 address resources , delete of them, when new post of new resource resource uri /api/v1/address/31/ instead of 1.
how can delete index when resource deleted?
thanks in advance victor
thats not possible if using autoincrement field, default primare key field django. want need specify own field primare key using primary_key=true attribute. , need set want manually when create new model instance.
Comments
Post a Comment