The modal accepts the POST data but does not save it.

Tried printing it out but it doesnt want to show sa command line.
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
Co-authored-by: 's avatarChristine <cdeeerrr@users.noreply.github.com>
parent 956452cb
...@@ -72,24 +72,31 @@ a{% extends 'boodlesite\templates\base.html' %} ...@@ -72,24 +72,31 @@ a{% extends 'boodlesite\templates\base.html' %}
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form action="auction/<int:pk>/" method="post"> <form action="" method="POST">
<div class="form-group"> <div class="form-group">
{% csrf_token %}
<label for="recipient-name" class="col-form-label">Enter Bid amount:</label> <label for="recipient-name" class="col-form-label">Enter Bid amount:</label>
<form id="form" method="post"> {% csrf_token %}
{{ form }}
<input type="number" class="form-control" id="amount"> <input type="number" class="form-control" id="amount">
</form>
<!--add an if else statement here re. floor price--> <!--add an if else statement here re. floor price-->
</div> {% for bid in auction_bids %}
</form> {% if bid.amount > item_floor_price %}
<!--How to make it post the bid and end up in data base and page-->
{% else %}
<h4>Please enter a price greater than the item's floor price</h4>
{% endif %}
{% endfor %}
</div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary">Confirm Bid</button> <button type = "submit" class="btn btn-secondary" name = "Submit"> Submit </button>
<!-- {% comment %} <button type="submit" class="btn btn-primary" value="Submit">Confirm Bid</button> {% endcomment %} -->
</div> </div>
</form>
</div> </div>
</div> </div>
......
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.http import HttpResponseRedirect
from django.http import HttpResponse from django.http import HttpResponse
from .models import * from .models import *
...@@ -35,6 +36,12 @@ def auction(request, pk): ...@@ -35,6 +36,12 @@ def auction(request, pk):
auction_item = auction.itemid auction_item = auction.itemid
form = PlaceBidForm()
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
print("Printing POST: ", request.POST)
print(auction_bids) print(auction_bids)
print(type(auction_bids)) print(type(auction_bids))
for bid in auction_bids: for bid in auction_bids:
...@@ -44,7 +51,8 @@ def auction(request, pk): ...@@ -44,7 +51,8 @@ def auction(request, pk):
'item_name':auction_item.itemname, 'item_name':auction_item.itemname,
'item_specs': auction_item.itemspecs, 'item_specs': auction_item.itemspecs,
'auction_bids' : auction_bids, 'auction_bids' : auction_bids,
'item_floor_price': auction_item.floorprice 'item_floor_price': auction_item.floorprice,
'form' : form
# need to make floor price object here # need to make floor price object here
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment