Hello,
I am currently developing a system to block users from updating a form data in case another user is also updating the same data at the same time.
My application uses REST API's with DRF and I choose to use
django-rest-framework-condition with the Etag decorator in order to have an optimistic locking approach.
What I understand is that the Etag is an identifier for a specific version of a resource
Let's say I have the following model
class Blog(models.Model):
name = models.CharField(max_length=100)
tagline = models.TextField()
So let's say in my view I want to return all entries from blog model
blog = Blog.objects.all()
Doesn't that mean that the Etag function should consider the value in blog variable when creating the identifier ?
From what I see, the django condition function assigns value to res_etag variable at the receiving of the HttpRequest before I can do any data query from database.
I do not quite understand how this can help me know if the entries from Blog have been modified by another user.
Could someone explain this mechanism ?
Thanks,
Cristian