activation_required render_to new_post html def create_post request sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
@activation_required()
@render_to('new_post.html')
def create_post(request):
"""
show form for creation of new post and create post on submit
"""
if request.method == 'POST':
data = request.POST.copy()
data['author'] = request.user.id
form = CreatePostForm(data)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/profile/')
else:
initial = {'author': request.user.id}
form = CreatePostForm(initial=initial)
return {'form': form}