Setting the order's next status

The next method from the Order model manager that we are going to create is the set_next_status method. The set_next_status method is just a method that can be used for convenience and it will set the next status of an order. If you remember, the Status enumeration that we created means that every item in the enumeration is set to auto(), which means that items in the enumeration will get a numeric sequential number as a value.

When we save an order in the database and set its status to, for example, Status.Processing, the value of the status field in the database will be 2.

The function simply adds 1 to the current order's status, so it goes to the next status item unless the status is Completed; that's the ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.