how to use 'redirect' and 'message' on django, python
<p>I am following the following tutorial link in order to create a page where there is login box, as well as a post form.</p>

<p>what im trying to accomplish here is to have only the people who are logged into the site be able to write on the post form, and submit the content.</p>

<p><a href="https://docs.djangoproject.com/en/1.9/topics/auth/default/" rel="nofollow">https://docs.djangoproject.com/en/1.9/topics/auth/default/</a></p>

<p>If you go to the link above, Under the 'How to log a user in' section, 
it basically tells me to use</p>

<p>'redirect to a success page'
and 'return a disabled account error message'and 
'return an invalid login error message'</p>

<p>the problem here is that, It's been only a few days that I started learning about python and django, and every time such function is necessary, i mostly cannot find any source to learn those functions, or get the codes from.</p>

<p>I already searched on google and stackoverflow for the 'redirection' but the example i was able to get was this:</p>

<pre><code>@app.route('/success/&lt;int:result_id&gt;')
def success(result_id):
 # replace this with a query from whatever database you're using
 result = get_result_from_database(result_id)
 # access the result in the tempalte, for example {{ result.name }}
 return render_template('success.html', result=result)
@app.route('/survey')
def survey():
if request.method == 'POST':
    # replace this with an insert into whatever database you're using
    result = store_result_in_database(request.args)
    return redirect(url_for('success', result_id=result.id))

# don't need to test request.method == 'GET'
return render_template('survey.html')
</code></pre>

<p>and i am yet to understand how the 'success' got in there inside 'redirect ()'</p>

<p>And here is the views.py that im currently working on.</p>

<pre><code>from django.contrib import messages
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404, redirect


from.forms import PostForm
from .models import Post


from django.contrib.auth import authenticate, login



def post_detail(request, id=None):
    #instance = Post.objects.get(id=1)
    instance = get_object_or_404(Post, id=id)
    context = {
        "title": instance.title,
        "instance": instance,
    }
    return render(request, "post_detail.html", context)

def post_list(request):

    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user is not None:
        if user.is_active:
            login(request, user)
            # Redirect to a success page.
        else:
            # Return a 'disabled account' error message
        else:
        # Return an 'invalid login' error message.

    form = PostForm(request.POST or None)

    if form.is_valid():
        instance = form.save(commit=False)
        print (form.cleaned_data.get("title"))
        instance.save()
        # message success
        messages.success(request, "Successfully Created")
        return HttpResponseRedirect(instance.get())
    #else:
        #messages.error(request, "Not Successfully Created")
    queryset = Post.objects.all()#.order_by("-timestamp")
    context = {
        "object_list": queryset,
        "title": "List",
        "form": form,
    }
    return render(request, "post_list.html", context)
    #return HttpResponse("&lt;h1&gt;List&lt;/h1&gt;")

def post_update(request, id=None):
    instance = get_object_or_404(Post, id=id)
    form = PostForm(request.POST or None, instance=instance)
    if form.is_valid():
        instance = form.save(commit=False)
        instance.save()
        # message success
        messages.success(request, "Saved")
        return HttpResponseRedirect(instance.get_absolute_url())
    context = {
        "title": instance.title,
        "instance": instance,
        "form":form,
    }
    return render(request, "post_form.html", context)


def post_delete(request, id=None):
    instance = get_object_or_404(Post, id=id)
    instance.delete()
    messages.success(request, "Successfully deleted")
    return redirect("posts:list")
</code></pre>

<p>is there any source i can get help regarding these kind of functions?</p>

<p>and also, are there any tutorials that cover how to implement the login form as well?</p>

<p>thank you.</p>