Alex Rivera | Logout

Django class-based views function execution order

Asked 2013-07-21T02:15:54.733
14

I'm converting some django views to be class based, and so far loving the flexibility.

Most of my views subclass from a parent view ClubView. Each subclassed view that needs to handle a post() method override needs to have access to the corresponding club value.

This value is in the URL, so the request variable has it. However, is there a way for me to grab this value, and fetch the corresponding club object outside of the post() method? like a pre-post() method or something. Mainly because I don't want to copy/paste club = Club.objects.get(...

A more general question -- in what order do all the methods execute in? Django's documentation on this seems lacking.

Edit
Report

1 Answer

0

You could write a get_club method in your parent class. You can then use this in your subclasses, and you don't have to repeat the logic.

answered 2013-07-21T08:54:57.820

Your Answer