def AddActivity(request): if request.method == "POST": form = AddActivityForm(request.POST, request.FILES) if form.is_valid(): post = form.save(commit = False) post.atorganizer = request.user post.save() return redirect('philosopher.views.activity.ActivityDetail', activityid = post.id ) else: form = AddActivityForm() return render_to_response('templates/philosopher/activityedit.html', {'form' : form}, context_instance = RequestContext(request) )
def EditActivity(request, activityid): activity = get_object_or_404(Activity, pk = activityid) user = activity.atorganizer if request.method == "POST": form = AddActivityForm(request.POST, request.FILES, instance=activity) if form.is_valid(): activity = form.save(commit = False) activity.atorganizer = user activity.save() return redirect('philosopher.views.activity.ActivityDetail', activityid = activity.id ) else: form = AddActivityForm( instance=activity) return render_to_response('templates/philosopher/activityedit.html', {'form' : form}, context_instance = RequestContext(request) )