*template:*

{% extends "posts/post_base.html" %}

{% load bootstrap3 %}

{% block post_content %}
<h4>{% if not form.instance.pk %}
Create Post
{% else %}
Update Post
{% endif %}</h4>
<form method="POST" id="postForm">
{% csrf_token %}
{% bootstrap_form form %}
<input type="submit" value="Post" class="btn btn-primary btn-large">
</form>
{% endblock %}


On Monday, 25 June 2018 23:47:07 UTC+5, alex eckert wrote:
>
> Can you include your template code? The issue could be in there.
>
> On Sunday, June 24, 2018 at 10:15:50 AM UTC-5, Saloni Kalra wrote:
>>
>> I wish to add radio buttons fill in each parameter of my model and also 
>> to convert it to integer on the backend. But somehow its not changing. 
>> Kindly help.
>> Thanks and regards,
>> Saloni
>>
>>
>> *Forms.py*
>>
>> class PostForm(forms.ModelForm):
>>
>>     class Meta:
>>         fields = ("teacher","subject","param1","param2","param3","param4",
>>                     
>> "param5","param6","param7","param8","param9","param10",)
>>         model = models.Post
>>         choices = (
>>                     (1,'Unsatisfactory'),
>>                     (2,'Satisfactory'),
>>                     (3,'Good'),
>>                     (4,'Very Good'),
>>                     (5,'Outstanding')
>>                     )
>>         widgets = {
>>                 'param1':forms.TypedChoiceField(choices=choices, 
>> widget=forms.RadioSelect, coerce=int),
>>
>>         }
>>
>> *Models.py*
>>
>> class Post(models.Model):
>>
>>     user = models.ForeignKey(User, related_name="posts", 
>> on_delete=models.CASCADE)
>>     teacher = models.ForeignKey(Teacher, related_name="posts", 
>> on_delete=models.CASCADE)
>>     subject = models.ForeignKey(Subject, related_name="posts", 
>> on_delete=models.CASCADE)
>>     created_at = models.DateTimeField(auto_now=True)
>>     param1 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "The objectives of this course were made clear to me by this 
>> teacher.")
>>     param2 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "The teacher speaks, articulates and explains concepts 
>> clearly.")
>>     param3 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "The teacher adheres to the timings schedule and enforces 
>> discipline in the class.")
>>     param4 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "Interest generated by the teacher.")
>>     param5 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "The lectures were well structured and focused on the 
>> topics.")
>>     param6 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "Accessibility of the teacher in and out of the class.")
>>     param7 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "The teacher has fair knowledge on the subject matter.")
>>     param8 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "Effective use of teaching aids.")
>>     param9 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "Time spend on lecturing by teacher for course coverage was 
>> sufficient and lesson plan was followed.")
>>     param10 = models.PositiveIntegerField(blank=False, null=False, 
>> verbose_name = "The teacher encourage students to raise pertinent questions 
>> and answer them.")
>>
>>     def __str__(self):
>>         return self.teacher.teacher_name
>>
>>     def get_absolute_url(self):
>>         return reverse(
>>             "posts:single",
>>             kwargs={
>>                 "username": self.user.username,
>>                 "pk": self.pk
>>             }
>>         )
>>
>>     class Meta:
>>         ordering = ["-created_at"]
>>         unique_together = ["user", "teacher", "subject"]
>>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1ca6807f-548a-4396-adfb-d5b85142422e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to