Hi guys,

I want to create a form with radio buttons that sends data to a specific
database field.  How can I do it?

My models.py looks like this:
import datetime
from django.db import models
from django.utils import timezone

# Create your models here.

class Name(models.Model):
    user_name = models.CharField(max_length=200)

    publication_date = models.DateTimeField('date published')

    age= models.IntegerField(default=0)

    prof_comm_score = models.IntegerField(default=1)
    prof_comm_status = models.IntegerField(default=1)

    teamwork_score = models.IntegerField(default=1)
    teamwork_status =  models.IntegerField(default=1)

    prod_knowledge_score =  models.IntegerField(default=1)
    prod_knowledge_status =  models.IntegerField(default=1)

    part_comp_score =  models.IntegerField(default=1)
    part_comp_status =  models.IntegerField(default=1)

    relations_score =  models.IntegerField(default=1)
    relations_status =  models.IntegerField(default=1)

    strategy_score =  models.IntegerField(default=1)
    strategy_status =  models.IntegerField(default=1)

    loyality_score =  models.IntegerField(default=1)
    loyality_status =  models.IntegerField(default=1)

    overall_score = models.IntegerField(default = 7)

    def __str__(self):
        return self.user_name
    def was_published_recently(self):
        return self.publication_date >= timezone.now() - datetime.timedelta(
days=1)

Lets say i want 7 radio buttons to determine the value of prof_comm_score
(which is an int ranging from 1 to 7)

My html file looks like this rn:
<body>
        {%block content%}
            <h1>#1 Sales profession, communication</h1>
            <form action="" method="POST"></form>
            {% csrf_token %}
                <input type="radio" name="1" id = "1" value="7">
                <input type="radio" name="1" id = "2" value="6">
                <input type="radio" name="1" id = "3" value="5">
                <input type="radio" name="1" id = "4" value="4">
                <input type="radio" name="1" id = "5" value="3">
                <input type="radio" name="1" id = "6" value="2">
                <input type="radio" name="1" id = "7" value="1">


        {%endblock%}
    </body>



here is my git repo if needed:
https://github.com/leocsi/salesgrade

Thanks a lot,
Leó

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJBcW0xearS3cj4XD%2BT0HEOCTvSSFMeJ18dvkjMaPdzwVfXf0w%40mail.gmail.com.

Reply via email to