I am confused that whether should I start a path starting with /
or not? For example, here is one method from my views.py
in django:
@login_required
def add_page(request,category_name_slug=None):
# check for post method
print category_name_slug
try:
cat = Category.objects.get(slug = category_name_slug)
except Exception, e:
cat = None
if request.method == 'POST':
print "sjhdfkjsdhkfhjs"
# means you submitted the form.
form = PageForm(request.POST)
a = form.is_valid()
if a:
if cat:
page = form.save(commit = False)
page.category = cat
page.views = 0
page.save()
print "sdjhfjshk"
return HttpResponseRedirect('/rango/category/' + category_name_slug + '/')
else:
print form.errors
else:
form = PageForm()
context_dict = {'form' : form,'category' : cat, 'slug': category_name_slug}
return render(request,'rango/add_page.html', context_dict)
In the render line
return render(request,'rango/add_page.html', context_dict)
the line is not started with /
. But, in case of following line:
return HttpResponseRedirect('/rango/category/' + category_name_slug + '/')
I have to start with /
. Please explain me when should I use '/' and when not.