Which is it better to use generally?
Is there any advantage to writing:
Or is it a direct alias? Is there any difference? Which is more pythonic/django-nic?
There is a difference between the two:
In the case of
HttpResponseRedirect the first argument can only be a
redirect which will ultimately return a
HttpResponseRedirect can accept a
url as it’s “to” argument. So it is a little more flexible in what it can “redirect” to.
I also like how
redirect is shorter. So I’d use
Both are fine to use though.
From documentation –
redirect(to[, permanent=False], *args, **kwargs)Returns an
HttpResponseRedirectto the appropriate URL for the arguments passed.
from the definition its the same. Thats what shortcuts are for. Both are one and the same.
shortcuts generally are written one level above the actual API’s. So
HttpResponsePermanentRedirect with the arg
There is no major downside to using
redirect. Hope this clears it.