From the course: Securing Django Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

How to ensure actions happen only once

How to ensure actions happen only once - Django Tutorial

From the course: Securing Django Applications

Start my 1-month free trial

How to ensure actions happen only once

- [Instructor] We're going to be using Jingles built in caching to add a throttle so that whenever a new package is created we do not allow more of them to be created for a short period of time. And in the Package Create View we're going to override the post method so that we check the cache for the package created key. And if that key has already been set we just return it 200. We did not create a new package object but the request is okay. However, if this key does not exist we are going to call, super post with the arguments and keyword arguments so that we actually create the object and we check the response and the status code to make sure that it did work correctly and if it did we're going to set the package created hit to true and it should time out in 300 seconds. After that we returned a response, okay. Let's run the Jingle web server. Now let's switch to a new terminal and we going to try running the…

Contents