choicefield

How to get the label of a choice in a Django ChoiceField?

I have a ChoiceField, now how do I get the "label" when I need it? class ContactForm(forms.Form): reason = forms.ChoiceField(choices=[("feature", "A feature"), ("order", "An order")], widget=forms.RadioSelect) form.cleaned_data["reason"] would only give me "...

choice property in google app engine

platform: django 1.0, google app engine, app-engine-patch , python 2.5.4 i am tring to use the choices attribute as i always have been using in django website STATUS_CHOICES = ( (1, _('Yet To Start')), (2, _('Running')), (3, _('Paused')), (4, _('Completed')), (5, _('Cancelled')), (6, _('Error')),) class Campaign(db.Model): name = ...

I need to add a choice field to sharepoint that has values depending on the current selection.

I need to add a choice field to sharepoint that has values depending on the current selection. Example: if the current selection is Open then the options have to be 'open, and In progress **Current selection | Possible selections** Open | Open,In progress In progress | In progress,To be communicates,rew...

Add an "empty" option to a ChoiceField based on model datas

Hello, I'm defining a ChoiceField based on a model's datas. field = forms.ChoiceField(choices=[[r.id, r.name] for r in Model.objects.all()]) However I'd like to prepend my options with an empty one to select "no" objects. But I can't find a nice way to prepend that. All my tests like : field = forms.ChoiceField(choices=[[0, '------...

Customizing RadioSelect

Hello I have a form with ChoiceField whose widget is set to RadioSelect Now to override default html output one needs to subclass RadioFieldRenderer like this: class SimpleRadioFieldRenderer(forms.widgets.RadioFieldRenderer): def render(self): """Outputs widget without <ul> or <li> tags.""" return mark_safe(u'\n'.j...

Django: provide choices list to a checkbox from a view function

Hi, in my Django application I've got a form with a ChoiceField that normally allows to choice between a range of integer values. class FormNumber(forms.Form): list=[] for i in range(1, 11): list.append((i,i)) number=forms.ChoiceField(choices=list, initial=1) Now I need to override the default choices list from a view method in some ...

Access Specific Choice Widget/Field from ChoiceField

Anyway to access the widget/render a specific choice from a ChoiceField? APPROVAL_CHOICES = ( ('true', 'Approve'), ('false', 'Re-Submit') ) class ProofApprovalForm(forms.Form): approved = forms.ChoiceField( choices=APPROVAL_CHOICES, widget=forms.widgets.RadioSelect ) Would like to access the choices i...

List display names from django models

I have an object: POP_CULTURE_TYPES = ( ('SG','Song'), ('MV', 'Movie'), ('GM', 'Game'), ('TV', 'TV'), ) class Pop_Culture(models.Model): name = models.CharField(max_length=30, unique=True) type = models.CharField(max_length=2, choices = POP_CULTURE_TYPES, blank=True, null=True) Then I have a function: def...

How to let the user choose between typing price inclusive VAT or exclusive VAT in TextField?

I am implementing an back-office application where the user type in prices for products. Sometimes it is preferred to type the price inclusive value-added-tax, VAT and sometimes exclusive VAT. How do I best let the user choose between the inclusive or exclusive VAT in a usability perspective? I could have two TextFields above eachother...

Storing multiple checkbox values in database

Hi, I want to store multiple column values in table.Lets take a example .. What are your favourite colors? the choices can be red,blue,green, orange. So lets assume, the user selects atleast 2 values. Is there any way to store the multiple values in table. I have implemented by concatinating choices of users in a column in the table....

cleaned_data() doesn't have some of the entered data

I have a simple form for a user to enter in Name (CharField), Age(IntegerField), and Sex(ChoiceField). However the data that is taken from the Sex choice field is not showing up in my cleaned_data(). Using a debugger, I can clearly see that the data is being received in the correct format but as soon as I do form.cleaned_data() all sign ...

Custom unicode on already created object

I'm using permissions in my application. And in some case I need to create form only with permission field. I'm using ModelChoiceField and queryset with permission objects. permission = forms.ModelChoiceField(queryset = Permission.objects.all()) But permissions unicode is taking too much place in choice field. And it looks not so goo...