Why is the permalink decorator no longer recommended in django? -


i reading django dev documentation. here says permalink decorator no longer recommended, use reverse inside get_absolute_url method generate full url model instance(scroll little above , check out warning box).

i think violating dry have use reverse each , every time need it. what's wrong using permalink? why no longer recommended?

in current versions of django, decorator literally calls reverse function documentation recommends anyway. reason seems decorator unnecessary have reverse(). using reverse nicer returning name, tuple, , dictionary. instead, use args , kwargs - idiomatic python.

and this ticket discussed deprecating decorator api purity sake. instead of raising warnings , making users update code bases, decided put warning in docs.

the permalink decorator should deprecated , removed. introduced solve problem of having hardcode urls get_absolute_url. violates 1 of major rules of decorators in in forces function signature change in order deal fact it's been decorated. additionally not provide useful functionality on using reverse() directly within body of get_absolute_url.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -