django - Can a Tastypie filter be applied to a detail resource? -


i have django model sequence_number field incremented each time model instance updated:

class foo(models.model):     bar = models.textfield()     sequence_number = models.integerfield(default=0) 

i have implemented tastypie resource model, so:

class fooresource(modelresource):     class meta:         queryset = foo.objects.all()         resource_name = 'foo'         list_allowed_methods = ['get']         detail_allowed_methods = ['put', 'get'] 

so client user can request particular instance of foo using url this:

http://.../api/foo/123/ 

clients applications retain sequence_number know version of object holding.

i want implement filter on detail resource client can pass sequence_number holding server:

  • if else has updated object since client's last request (so server sequence_number greater client sequence_number) resource should return updated object.
  • if server sequence_number unchanged, resource should return nothing (or empty fields etc.).

i tried implement adding filter resource meta:

    filter = {         'sequence_number': ('gt',),     } 

and using following url:

http://.../api/foo/123/?sequence_number__gt=123 

but had no effect. did work when used list resource i.e.

http://.../api/foo/?sequence_number__gt=123 

so - possible configure tastypie accept filters on detail resources? if not, suggestions how should roll own solution (while still using tastypie)?


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -