Thnx. The reason the grade values are 4.33, 4. 3.67 etc is because that value is multiplied by the value entered for ha_credithours and hp_credithours. If there's a better way to do this from the beginning, like changing the values for the grade_choices and then multiplying it different in my views that'd be fine as well...
On Feb 2, 10:56 am, Shawn Milochik <sh...@milochik.com> wrote: > On Feb 2, 2010, at 10:40 AM, Chris McComas wrote: > > > Here's my view: > > >http://dpaste.com/153735/ > > > One thing I just thought of, is it a problem that the data for > > ha_grade and hp_grade are saved in the db as 4.3300 or 4.0000 or > > 3.6700 but in the <select> on my form they're like this: 4.33 or 4.0 > > or 3.67 ??? > > Your guess sounds likely. I wanted to see the view to see if anything was > going on with the grades, but it doesn't appear so. > > Here's a hacky fix that should work (untested). Hopefully someone can offer > the proper solution once they see this ugliness: > > Add this to your ModelForm: > > def __init__(self, *args, **kwargs): > > super(GreenSheetsForm, self).__init__(self, *args, **kwargs) > > if self.instance: > for choice_id, choice_text in self.fields['hp_grade'].choices: > if Decimal(choice_id) == self.instance.hp_grade: > self.fields['hp_grade'].initial = choice_id > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.