예제 #1
0
파일: views.py 프로젝트: RamiliaR/django
def edit_order(request, details_id):
    order = Details.objects.get(pk=details_id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            form = DetailsForm(request.POST, instance=order)
            form.save()
            return redirect('congratulation:congr', details_id )
    else:
        form = DetailsForm(instance=order)
    return render(request, 'congratulation/edit_order.html', {'username':auth.get_user(request).username, 'form': form, 'id':details_id})
예제 #2
0
파일: views.py 프로젝트: RamiliaR/django
def order(request):
    current_user = request.user
    c = Customer.objects.get(user_id = current_user.id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            a = Details.objects.create(customer_id=c.id, date=datetime.now())
            form = DetailsForm(request.POST, instance=a)
            form.save()
            return HttpResponseRedirect('/congratulation/detail')
    else:
        form = DetailsForm()
    return render(request, 'congratulation/add_order.html', {'username':auth.get_user(request).username, 'form': form, 'id':c.id})
예제 #3
0
def edit_order(request, details_id):
    order = Details.objects.get(pk=details_id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            form = DetailsForm(request.POST, instance=order)
            form.save()
            return redirect('congratulation:congr', details_id)
    else:
        form = DetailsForm(instance=order)
    return render(
        request, 'congratulation/edit_order.html', {
            'username': auth.get_user(request).username,
            'form': form,
            'id': details_id
        })
예제 #4
0
def order(request):
    current_user = request.user
    c = Customer.objects.get(user_id=current_user.id)
    if request.method == 'POST':
        form = DetailsForm(request.POST)
        if form.is_valid():
            a = Details.objects.create(customer_id=c.id, date=datetime.now())
            form = DetailsForm(request.POST, instance=a)
            form.save()
            return HttpResponseRedirect('/congratulation/detail')
    else:
        form = DetailsForm()
    return render(request, 'congratulation/add_order.html', {
        'username': auth.get_user(request).username,
        'form': form,
        'id': c.id
    })