I'm implementing a rest api using django-tastypie. My api resource is defined as 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 a 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 to the url http://mydomain.com/api/v1/Address/. After Address resource creation the resource uri is /api/v1/Address/1/..../api/v1/Address/2/....etc
If I delete the resources directly from the model database or by doing a HTTP DELETE of the resource http://mydomain.com/api/v1/Address/2/, when I do a new post of a resource the id of the resource uri is still incrementing based on the last index.
Example: I have 30 address resources and I delete all of them, when I do a new post of a new resource the resource uri is /api/v1/Address/31/ instead of 1.
How can I delete the index when a resource is deleted?
Thanks in advance Victor