How to avoid hardcode URL in Django view -
i working on simple project on django. views implementing return hardcode path:
def temp_view(request): ... return render("app/detail.html") or
def temp_view_2(request): ... return redirect("/app/view2") what want rid of hardcode url (for view url , template url). there proper way that?
thanks.
django provides few different methods. in view, django.core.urlresolvers.reverse() function used. full discussion of problem , options provided django here:
https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-resolution-of-urls
Comments
Post a Comment