Questions tagged [choicefield]

202 questions
1
vote
2 answers

Django forms ChoiceField not selecting the wanted value

I created a django form (IssueForm) which is meant to be used to register an object which is instance of one of my models (Issue). Following are the model: model.py class Issue(models.Model): TYPE_FIELDS = [ ("Math", "Math"), ("Physics",…
Giacomo Casoni
  • 387
  • 2
  • 16
1
vote
2 answers

Create SharePoint Choice Fields with PowerShell

I want to be able to create a list and choice column with PowerShell but the Choice column always fails. I have found a few examples showing my code to work so I must be missing something. MSDN Link to Add field clear Add-PSSnapin…
Swazimodo
  • 1,147
  • 1
  • 15
  • 34
1
vote
1 answer

Django Models with Choices as Integer

I am trying to make a feedback app in Django, but I can not make my evaluations. In my models.py, I have 5 choices from very bad to excellent. But I want them to be usable as numbers so I can evaluate the overall value. After reading Set Django…
user7084802
1
vote
0 answers

Django ChoiceField not working insed {% for sub in subs %}

Inside my django project i have a template called formquestions.html. Inside the template I am looping through all sub categories from my database (right now it is only 1 for testing purposes). My issue is that my ChoiceField is not dropping down so…
jefpadfi
  • 183
  • 1
  • 17
1
vote
1 answer

How can I override choices of abstract class?

I have AbstractProfile model with predefined PRIVACY_CHOICES: class AbstractProfile(models.Model): PRIVACY_CHOICES = ( (1, _('all')), (2, _('no one')), ) title = models.CharField(_('title'), max_length=30) info =…
TitanFighter
  • 4,582
  • 3
  • 45
  • 73
1
vote
1 answer

Display human readable choice in template

I have seen the posts on this already Display forms choice in template-Django and they recommend using in the template {{ item.get_categories_display }} but my set up is a little different, so I can't access the human readable elements in…
Shane G
  • 3,129
  • 10
  • 43
  • 85
1
vote
1 answer

Subclassing django choicefield doesn't work

I'm trying to subclass the ChoiceField so I can use it in multiple forms (DRY). For example: class testField(forms.ChoiceField): choices = (('a', 'b'), ('c', 'd')) label = "test" class testForm(forms.Form): test = testField() Other types of…
dwagon
  • 501
  • 3
  • 9
1
vote
0 answers

django and editable and multiselect choices in ChoiceField

I'm trying to get a field of model in Django, which will behave like a ChoiceField but: will support multiselect would allow to edit the list of choices For example - I've got a product, which belongs to several cathegoris: nice, for boys, for men…
Dejwi
  • 4,393
  • 12
  • 45
  • 74
1
vote
1 answer

Django choices with model objects

Yes, this is an assignment, and yes, I've spent some time on it and now I need help. My task has two models, Server and Client and they are in 1-N relationship. as noted below # models.py class Server(models.Model): name =…
ivica
  • 1,388
  • 1
  • 22
  • 38
1
vote
2 answers

Django ChoiceField initial setup not working

I have ModelForm where i use Django Forms.ChoiceField. Writing the value to the database works. But when i open the url, the dropdown list is not showing the previously selected value as selected value. I tried setting initial=value, but it's not…
user1159517
  • 5,390
  • 8
  • 30
  • 47
1
vote
2 answers

How to dynamic loading the field of ChoiceField in form using the database in Django?

Just like the answer,I want to dynamic Load the database in the choicefield, and i had do this queue = forms.ChoiceField(label=u'queue',choices=((x.que,x.disr) for x in Queue.objects.all())) but it doesn't work ,i must restart the server,the field…
junfeng
  • 33
  • 3
1
vote
1 answer

Django - Divide query into subgroups by attribute

I have a model that looks like this: class ListEntry(models.Model): STATUS_CHOICES = ( ('PL', _('Playing')), ('CO', _('Completed')), ('OH', _('On-hold')), ('DR', _('Dropped')), ('WA', _('Want to play')), …
Aylen
  • 3,524
  • 26
  • 36
1
vote
2 answers

Django 1.6 name select is not defined

I'm trying to show a dropdown menu in my template, but I get the following error File "forms.py" in DropdownSelectionForm 101. selection = forms.ChoiceField(choices=MY_CHOICES, widget = Select) Exception Type: NameError at / Exception Value:…
James L.
  • 1,143
  • 22
  • 52
1
vote
0 answers

Render new fields depending on choice in Django

I'm working on a Django project right now and when adding a Right model I want the form to look different depending on what is chosen in the attribute 'type'. Here's my code: models.py class Right(models.Model): RIGHT_TYPE_CHOICE = ( ('NR',…
axelniklasson
  • 55
  • 1
  • 8
1
vote
0 answers

how to relate to django choice field in a same model

I have a Event model with two fields category and sub_category . Both of them are choice fields here are choices : Category_Choices ( ('1','a') ('2','b') ) A_SubCategory_Choices( ('1','x') ('2','y') …
Nima
  • 490
  • 2
  • 10
  • 19