(request)
return render(request, "new_post.html", context=context)
Creates a new post
Creates a new post
Creates a new post
def new_post(request):
    """
    Creates a new post
    """
    title = request.GET.get('title', '')
    tag_val = request.GET.get('tag_val', '')
    tag_val = ','.join(tag_val.split())
    initial = dict(title=title, tag_val=tag_val)
    content = ''
    author = request.user
    form = forms.PostLongForm(user=request.user, initial=initial)
    if request.method == "POST":

        form = forms.PostLongForm(data=request.POST, user=request.user, initial=initial)
        tag_val = form.data.get('tag_val')
        content = form.data.get('content', '')
        if form.is_valid():
            # Create a new post by user
            title = form.cleaned_data.get('title')
            content = form.cleaned_data.get("content")
            ptype = form.cleaned_data.get('post_type')
            tag_val = form.cleaned_data.get('tag_val')
            post = auth.create_post(title=title, content=content, ptype=ptype, tag_val=tag_val, author=author,
                                    request=request)

            tasks.created_post.spool(pid=post.id)

            return redirect(post.get_absolute_url())

    # Action url for the form is the current view
    action_url = reverse("post_create")
    context = dict(form=form, tab="new", tag_val=tag_val, action_url=action_url,
                   content=content)

    return render(request, "new_post.html", context=context)
def new_post ( request ) : title = request . GET . get ( 'title' , '' ) tag_val = request . GET . get ( 'tag_val' , '' ) tag_val = ',' . join ( tag_val . split ( ) ) initial = dict ( title = title , tag_val = tag_val ) content = '' author = request . user form = forms . PostLongForm ( user = request . user , initial = initial ) if request . method == "POST" : form = forms . PostLongForm ( data = request . POST , user = request . user , initial = initial ) tag_val = form . data . get ( 'tag_val' ) content = form . data . get ( 'content' , '' ) if form . is_valid ( ) : # Create a new post by user title = form . cleaned_data . get ( 'title' ) content = form . cleaned_data . get ( "content" ) ptype = form . cleaned_data . get ( 'post_type' ) tag_val = form . cleaned_data . get ( 'tag_val' ) post = auth . create_post ( title = title , content = content , ptype = ptype , tag_val = tag_val , author = author , request = request ) tasks . created_post . spool ( pid = post . id ) return redirect ( post . get_absolute_url ( ) ) # Action url for the form is the current view action_url = reverse ( "post_create" ) context = dict ( form = form , tab = "new" , tag_val = tag_val , action_url = action_url , content = content ) return render ( request , "new_post.html" , context = context )