I am pretty bad at stating my problem clearly. Sorry.
Basically, I have many view functions whose functionalities are very similar. Part of it is using reverse. However, each of those view functions execute different reverse, so I cannot write them one by one in my new “generic view”. That’s insane.
At the time, I am trying to reduce the amount of duplicated codes I am writing (that’s over 500 lines of duplication!!!!!)
To solve this problem, I have a few helper functions, one of which is to evaluate reverse on whatever view function is given and whatever args are passed to the helper function.
def render_reverse(f, args):
return eval(...)
But eval is evil, and is slow. Any substitute for eval? A better approach to solve this in Django?
Thanks.
Why do you need to
evalat all in the first place? Just callreverse()normally?The
*lets you unpack the argument list into actual args.That said, why do you need this helper at all? Why not just put
return reverse(...in your view?