Ejemplo n.º 1
0
Archivo: views.py Proyecto: motto7/maps
def edit_plan(request, pk):
    post = get_object_or_404(Post, pk=pk)

    if request.method == 'POST':
        form = PostForm(request.POST, request.FILES, instance=post)

        if form.is_valid():
            form.save()
            messages.info(request, "수정이 되었습니다.")
            return redirect('magazine:index')

    else:
        form = PostForm(instance=post)

    return render(request, "plan/form.html", {
        'form': form,
    })
Ejemplo n.º 2
0
Archivo: views.py Proyecto: motto7/maps
def create_plan(request):
    if request.method == 'POST':

        form = PostForm(request.POST, request.FILES)

        if form.is_valid():
            post = form.save(commit=False)
            post.author = request.user
            post.save()
            #form.save_m2m()

            messages.success(request, "새 계획이 추가되었습니다.")

            return redirect('plan:index')

    else:
        form = PostForm()

    return render(request, "plan/form.html", {
        'form': form,
        })