could you tell me what"s wrong with my form? Why can"t the data be submitted?
<form class="ui form" method="post" action="{% url "users:my_recharge" %}">
{% csrf_token %}
<div class="left icon field">
<label> :</label>
<input id="id_amount" type="text" name="amount" placeholder="">
</div>
<div class="field">
<label> :</label>
<select name="currency">
<option value="jpy"> -JPY</option>
<option value="usd">US -USD</option>
</select>
0Paypal
</div>
{-sharp <input type="text" name="rate" value="17.12" hidden>-sharp}
<input type="text" name="admin_pay_type" value="PP" hidden>
<input type="text" name="pay_type" value="7" hidden>
<input type="checkbox" value="True" name="a_type" hidden>
<div class="field">
<!-- <div class="ui checkbox">
<input type="checkbox" tabindex="0" class="hidden">
<label></label>
</div> -->
</div>
<button class="fluid mini ui red button" type="submit"><i class="large paypal icon"></i> </button>
</form>
users/forms.py:
class UserRechargeForm(forms.ModelForm):
class Meta:
model = UserBalance
fields = ["pay_type", "amount", "admin_pay_type", "currency", "rate", "a_type"]
users/view.py:
class MyRechargeView(LoginRequiredMixin, View):
def get(self, request):
return render(request, "recharge.html", {})
def post(self, request):
user = UserProfile.objects.get(username=request.user.username)
new_recharge = UserBalance(user=user)
user_balance_form = UserRechargeForm(request.POST, instance=new_recharge)
if user_balance_form.is_valid():
user_balance_form.save()
return HttpResponseRedirect(reverse("/"))
else:
user_balance_form = UserRechargeForm()
return render(request, "recharge.html", {"user_balance_form": user_balance_form})