Here is my form class class StationInfo( forms.Form):
def __init__( self, *args, **kwargs): super( StationInfo, self).__init__( *args, **kwargs) request = args[1] selecttuple = "choice0", "--Select One--" userid = threadlocals.get_current_user() user = '%s' % userid userrec = User.objects.get(username=user) projrecs = UserProj.objects.filter( User=userrec) self.projlist = [] phaselist = [] for proj in projrecs: self.projlist.append( proj.ProjectId) # Get all the configurations for a station stationrec = request.session['stationrec'] configlist1 = Configuration.objects.filter( ConfigurationType='Station', AdditionalEquipFlag=False) configlist2 = Configuration.objects.filter( ConfigurationType='Station', AdditionalEquipFlag=True).order_by('ConfigurationName') configlist = list(chain(configlist1, configlist2)) for config in configlist: config_str = '%s' % config foundconfig = True # Get station configuration record for given station configstr_list = [] try: stationconfiglist = StationConfig.objects.filter( ConfigValueId__ConfigurationId__ConfigurationName=config.ConfigurationName, EndDate__isnull=True, StationId=stationrec ) if len(stationconfiglist) == 0: foundconfig = False else: for stationconfigrec in stationconfiglist: configstr = '%s' % stationconfigrec.ConfigValueId configstr_list.append( configstr) except: foundconfig = False # Get choice list choicelist = [] if config_str == 'Phase' or config_str == 'Project': configvalues = ConfigValues.objects.filter( ConfigurationId__ConfigurationName=config.ConfigurationName ).order_by( 'ConfigValue') else: configvalues = ConfigValues.objects.filter( ConfigurationId__ConfigurationName=config.ConfigurationName, ProjectId__in = self.projlist).order_by( 'ConfigValue') if not foundconfig: if config.MultiSelectFlag: choicelist.append( selectmoretuple) else: choicelist.append( selecttuple) select_fieldlist = [] allchoiceslist = [] for configrec in configvalues: configvalstr = '%s' % configrec allchoiceslist.append( configvalstr) choicestr = "choice%s" % str( configrec.id) choicetuple = choicestr, configrec.ConfigValue if configrec.ConfigValue in configstr_list: choicelist.insert( 0, choicetuple) select_fieldlist.append( choicestr) else: choicelist.append( choicetuple) for stationconfigrec in stationconfiglist: configstr = str( stationconfigrec.ConfigValueId) # Tried if not in list but it gave incorrect result found = False for choice in allchoiceslist: if configstr == choice: found = True break if not found: choicestr = "choice%s" % str( stationconfigrec.ConfigValueId.id) choicetuple = choicestr, configstr choicelist.insert( 0, choicetuple) select_fieldlist.append( choicestr) if config.MultiSelectFlag: self.fields[config.ConfigurationName] = forms.MultipleChoiceField( choices=choicelist, required=False, widget = MyMultiSelectWidget(initial=select_fieldlist )) else: print 'config name is ', config.ConfigurationName self.fields[config.ConfigurationName] = forms.ChoiceField( choices=choicelist, required=False) if config.ExpireFlag: for stationconfigrec in stationconfiglist: config_valuestr = '%s' % stationconfigrec.ConfigValueId print 'config value string is ', config_valuestr fieldname = ( config_valuestr + ' ' + config.ConfigurationName + ' CalibrationDueDate (US/Central Time)') print 'field name is ', fieldname if stationconfigrec.ExpireDate == None: self.fields[fieldname] = forms.SplitDateTimeField( required=False, widget = MySplitDateTimeWidget()) else: startdatetime = '%s' % stationconfigrec.ExpireDate datelist = startdatetime.split(' ') self.fields[fieldname] = forms.SplitDateTimeField( required=False, widget = MySplitDateTimeWidget(datevalue=datelist[0], timevalue=datelist[1])) if config.ConfigurationName != 'Phase': delete_field = config.ConfigurationName + 'DeleteFlag' self.fields[delete_field] = forms.BooleanField( required=False) On Thu, Jul 29, 2010 at 5:31 PM, Jason <goodri...@gmail.com> wrote: > Post the form class (or model if you are generating it from a model). > > On Jul 29, 3:17 pm, Jeff Green <jeffhg2...@gmail.com> wrote: > > For example, the field name is Programmer Serial Number but it is being > > displayed > > as Programmer serial number > > > > I have not had this issue in 1.1.1. I was wondering if there was a way to > > ignore the conversion. > > > > On Thu, Jul 29, 2010 at 5:02 PM, Jason <goodri...@gmail.com> wrote: > > > I think Django's been doing that for a long time (not just 1.2.1). > > > > > Probably the quick and easy way to change case would be to use just > > > field.label and pump it into whatever format you want: > > > > > {{ field.label|upper }} > > > > > You'll have to manually create the rest of the html for the label > > > using field.html_name > > > > > I've run into some slight problems figuring out the proper id's for > > > the corresponding labels... Normally it's just > > > id_{{ field.html_name }} but if you get into auto_id's as well as > > > labels for more complex things (radio button lists, etc) it can get a > > > little bit funky. > > > > > On Jul 29, 2:42 pm, Jeff Green <jeffhg2...@gmail.com> wrote: > > > > With Django 1.2.1 it seems that my html template causes the > > > > field.label to display > > > > in lower case except for the first character. Has anyone experienced > > > > this before and how do you > > > > get it display without lower case conversion > > > > > > My html template snippet is: > > > > > > {% for field in form %} > > > > > > {{ field.label_tag}} > > > > > > Thanks, > > > > Jeff > > > > > -- > > > 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<django-users%2bunsubscr...@googlegroups.com> > <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > > > > -- > 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<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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.