This is my html code for checkbox :
<div class="col">
<div class="form-check"><input class="form-check-input" type="checkbox" id="formCheck-1"><label class="form-check-label" for="formCheck-1" style="color:rgb(255,255,255);">Melody</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="formCheck-1"><label class="form-check-label" for="formCheck-1" style="color:rgb(255,255,255);">Rock</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="formCheck-1"><label class="form-check-label" for="formCheck-1" style="color:rgb(255,255,255);">Classical</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="formCheck-1"><label class="form-check-label" for="formCheck-1" style="color:rgb(255,255,255);">Jazz</label></div>
<div class="form-check"><input class="form-check-input" type="checkbox" id="formCheck-1"><label class="form-check-label" for="formCheck-1" style="color:rgb(255,255,255);">Metal</label></div>
</div>
Views.py (I am very new to programming, so the code could be wrong)
def Userregister(request):
if request.method == 'POST':
Name = request.POST['Name']
Melody = request.POST.getlist['Melody']
Rock = request.POST.getlist['Rock']
Jazz = request.POST.getlist['Jazz']
Classical = request.POST.getlist['Classical']
Metal = request.POST.getlist['Metal']
models.py
from django.db import models
class User(models.Model) :
Name= models.CharField(max_length=100)
Melody = models.BooleanField(default=False)
Rock = models.BooleanField(default=False)
Jazz = models.BooleanField(default=False)
Classical = models.BooleanField(default=False)
Metal = models.BooleanField(default=False)
Aucun commentaire:
Enregistrer un commentaire