Re: Filtering ChoiceField by Multiple id's and same value ('name')

2020-08-29 Thread Yvonne Calhoun Pasquali
fields (1 Choicefield and 2 ModelChoicefields): > The Choicefield displays names of objects by id's. However, in my db, I > have multiple objects with the same name. I am trying to filter these > objects by "species" and "gender" (the two ModelChoiceFields).

Filtering ChoiceField by Multiple id's and same value ('name')

2020-08-29 Thread Yvonne Calhoun Pasquali
Hello, I have a form with three fields (1 Choicefield and 2 ModelChoicefields): The Choicefield displays names of objects by id's. However, in my db, I have multiple objects with the same name. I am trying to filter these objects by "species" and "gender" (the t

ChoiceField in from module not working

2020-08-05 Thread Kovy Jacob
I am trying to have a ChoiceField in a form, but it gives me this error: from TachlisGeredt.register_form import register File "/Users/kovyjacob/TachlisGeredt/TachlisGeredt/register_form.py", line 10, in class RegisterForm (forms.Form): File "/Users/kovyjaco

django forms exclude values from choicefield

2020-01-05 Thread Muhammad Mahir
I want to exclude those options from the ChoiceField in the forms that has been already selected and are into the database. Below is the Code. models.py SEMESTER_CHOICES = ( ("1", "1"), ("2", "2"), ("3", "3"), ("

django forms exclude values from choicefield that are already into database

2020-01-05 Thread Muhammad Mahir
I want to exclude those options from the ChoiceField in the forms that has been already selected and are into the database. Below is the Code. models.py ``` SEMESTER_CHOICES = ( ("1", "1"), ("2", "2"), ("3", "3"),

Re: Decisions on selcting ChoiceField

2019-12-24 Thread shree hari
can you please show me the implementation with respect to my code ? On Tuesday, December 24, 2019 at 7:03:23 PM UTC+5:30, Nitin Kalmaste wrote: > > You can do request.get[field name] > And make your conditions in views > > On Tue 24 Dec, 2019, 6:50 PM shree hari, > wrote: > >> # views.py >> def p

Re: Decisions on selcting ChoiceField

2019-12-24 Thread shree hari
Thank you. Will give it a try. On Tuesday, December 24, 2019 at 7:03:23 PM UTC+5:30, Nitin Kalmaste wrote: > > You can do request.get[field name] > And make your conditions in views > > On Tue 24 Dec, 2019, 6:50 PM shree hari, > wrote: > >> # views.py >> def price_choices(request): >> if requ

Re: Decisions on selcting ChoiceField

2019-12-24 Thread shree hari
Thank you. Will give it a try. On Tuesday, December 24, 2019 at 7:03:23 PM UTC+5:30, Nitin Kalmaste wrote: > > You can do request.get[field name] > And make your conditions in views > > On Tue 24 Dec, 2019, 6:50 PM shree hari, > wrote: > >> # views.py >> def price_choices(request): >> if requ

Re: Decisions on selcting ChoiceField

2019-12-24 Thread Nitin Kalmaste
You can do request.get[field name] And make your conditions in views On Tue 24 Dec, 2019, 6:50 PM shree hari, wrote: > # views.py > def price_choices(request): > if request.method == "GET": > context = {} > context['form'] = pricechoice() > return render( request, "te

Decisions on selcting ChoiceField

2019-12-24 Thread shree hari
# views.py def price_choices(request): if request.method == "GET": context = {} context['form'] = pricechoice() return render( request, "template_form.html", context) # forms.py price_CHOICES =( ("1", "25"), ("2", "50"), ("3", "100"), ("4", "200"),

Django formset, forms passing unique choices into a choicefield for each form

2019-12-18 Thread Brad Allgood
Initially posted on stack overflow: https://stackoverflow.com/questions/59395761/passing-dynamic-choices-into-a-formset-unique-for-each-form I am working on what I thought was a simple college football confidence pool. The concept is as follows: - Bowl Model: Model that stores information of

Re: ChoiceField avec valeur cochée par défaut

2018-03-01 Thread Simon Charette
Bonsoir Niche, Tu devrais être en mesure d'y arriver en t'assurant que le formulaire (Form) comprenant ce champ ait ta valeur ta valeur par défaut comme initial data. exemple class MyForm(forms.Form): field = ChoiceField(widget=widgets.RadioSelect, choices=['un', 

ChoiceField avec valeur cochée par défaut

2018-03-01 Thread Niche
Bonjour! comment faire pour avoir un radiobox (ChoiceField) coché avec une valeur par defaut ? -- 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 dj

How to change option HTML elements' attribute of ChoiceField?

2017-12-15 Thread Taka Hi
I want to change option HTML attributes per option. example: ``` 1. a 2. b ``` I think that it is needed to pass extra-data from ChoiceField to ChoiceWidget Select. How can I do this? -- You received this message because you are subscribed to the Google Groups "Django users&q

Re: Nullable ChoiceField on ModelForm - has_changed always True

2016-01-20 Thread James Schneider
On Tue, Jan 19, 2016 at 4:45 PM, steve byerly wrote: > Also of note, I recently upgraded to Django 1.9 from Django 1.7 where this > was working fine. It looks like this commit is the cause of my problem: > > https://github.com/django/django/commit/ff077cd6496b6f82195e2dc040f70e19e7c206c9 > > Is t

Re: Nullable ChoiceField on ModelForm - has_changed always True

2016-01-20 Thread steve byerly
It actually looks like the commit fixed the regression and was in 1.9.1. Didn't realize it had been released. On Tuesday, January 19, 2016 at 4:45:52 PM UTC-8, steve byerly wrote: > > Also of note, I recently upgraded to Django 1.9 from Django 1.7 where this > was working fine. It looks like thi

Re: Nullable ChoiceField on ModelForm - has_changed always True

2016-01-19 Thread steve byerly
Also of note, I recently upgraded to Django 1.9 from Django 1.7 where this was working fine. It looks like this commit is the cause of my problem: https://github.com/django/django/commit/ff077cd6496b6f82195e2dc040f70e19e7c206c9 On Tuesday, January 19, 2016 at 4:23:00 PM UTC-8, steve byerly wrote:

Nullable ChoiceField on ModelForm - has_changed always True

2016-01-19 Thread steve byerly
I have a model with a nullable field (PositiveSmallIntegerField) with defined choices. When I make a ModelForm for the model and do not select a value for this field, the field always comes back in the changed data. The reason is that the empty choice value, the data_value, is an empty string,

Re: loop a ChoiceField SelectMultiple form in the view as post

2015-07-13 Thread Vijay Khemlani
To tell you the truth I'm not quite sure what are you trying to accomplish, but for starters if you have a select multiple widget then your form field should be a forms.MultipleChoiceField On Mon, Jul 13, 2015 at 4:38 PM, dk wrote: > I made a quick project with an app, that might be easier to s

Re: loop a ChoiceField SelectMultiple form in the view as post

2015-07-10 Thread dk
i might simplify lol i didnt even understand. after i validate and clean a ChoiceField how do i us it? does it return a directory saying whats selected? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this grou

loop a ChoiceField SelectMultiple form in the view as post

2015-07-09 Thread dk
i made a from lista = (("1","one"), ("2", "two")) pending = forms.ChoiceField(widget=forms.SelectMultiple, choices=lista) I do get it as post method. I do get true with is_valid() it renders properly in the website. but when I press the submit button. and I am printing the form.cleaned_data[

Re: How to properly set the initial value for a Form ChoiceField

2015-01-23 Thread Vijay Khemlani
#x27;].initial = str(selected_image) self.fields['*flavors*'].initial = str(selected_flavor) ? On Fri, Jan 23, 2015 at 8:27 PM, Eugene Goldberg < eugene.goldberg...@gmail.com> wrote: > Hello, > In my Form I have a couple of ChoiceField fields, for which I need to set &g

How to properly set the initial value for a Form ChoiceField

2015-01-23 Thread Eugene Goldberg
Hello, In my Form I have a couple of ChoiceField fields, for which I need to set a default / initial value. I'm trying to do this in the __init__, and my debug shows, that these values do take, but, when the actual html forms shows up, my default values are not set as desired. Am I mi

Re: Problme in creating dynamic ChoiceField

2014-08-05 Thread VIPUL BANSAL
Hi Daniel, It worked. Thanks a lot :) On Tuesday, August 5, 2014 7:08:34 PM UTC+5:30, Daniel Roseman wrote: > > On Tuesday, 5 August 2014 13:28:28 UTC+1, VIPUL BANSAL wrote: >> >> Hi, >> >> I trying to create a drop-down which gets repopulated every time we land >> on the page. >> >> If I use th

Re: Problme in creating dynamic ChoiceField

2014-08-05 Thread Daniel Roseman
On Tuesday, 5 August 2014 13:28:28 UTC+1, VIPUL BANSAL wrote: > > Hi, > > I trying to create a drop-down which gets repopulated every time we land > on the page. > > If I use the following code everything works correctly: > > class DeleteMappingForm(forms.Form) : > subAreaDropDown = forms.Choi

Problme in creating dynamic ChoiceField

2014-08-05 Thread VIPUL BANSAL
Hi, I trying to create a drop-down which gets repopulated every time we land on the page. If I use the following code everything works correctly: class DeleteMappingForm(forms.Form) : subAreaDropDown = forms.ChoiceField(choices = fetchChoices()) def deleteMapping(request): form = D

Django ChoiceField usage

2014-05-08 Thread sravani v
Hi, I am new to Django. I am trying to working out on the different fields in this. From that only I found there are model fields and form fields existed in it. Now I am working on radio buttons. For this what I have done is,created a model with field "title = models.CharField(max_length=3, ch

change the default value choicefield

2014-04-27 Thread Helton Alves
Hi guys, I'm new here on the list. I have a question. yesterday I needed create a form with some fields and one the field was using select with choicefield. I needed edit in label default of select. was as follows: I wanted like this: Your state I done like this: get the

Re: Django admin - dinamically update through ajax choices of a ChoiceField in a ModelForm

2013-09-21 Thread C. Kirby
select rendered are dinamically updated > through ajax functions. > The problem is that while saving, the selected options is recognized as > not valid cause is not in the initial choices: > > Select a valid choice. is not one of the available choices. > > Any idea on how to solv

Django admin - dinamically update through ajax choices of a ChoiceField in a ModelForm

2013-09-21 Thread luke lukes
the options of those html select rendered are dinamically updated through ajax functions. The problem is that while saving, the selected options is recognized as not valid cause is not in the initial choices: Select a valid choice. is not one of the available choices. Any idea on how to solve it?

Re: Help with Dynamic ChoiceField

2013-03-25 Thread Dilip M
On Mon, Mar 25, 2013 at 4:54 PM, Dilip M wrote: > Hi, > > I am trying to fill in *choices *for MultipleChoiceField in runtime. I > am using formWizard and trying to return the dictionary using get_form_kwargs. > > > I am able set the *initial* for CharField but not *choices *for > MultipleChoic

Help with Dynamic ChoiceField

2013-03-25 Thread Dilip M
Hi, I am trying to fill in *choices *for MultipleChoiceField in runtime. I am using formWizard and trying to return the dictionary using get_form_kwargs. I am able set the *initial* for CharField but not *choices *for MultipleChoiceField. I am trying to show up dynamic choices based on the user'

Re: Model ChoiceField?

2012-08-30 Thread Lachlan Musicman
Ok, ignore this email - I've just realised one is a Form field, and the other is a Model field. Apols for stupid. Cheers L. On Fri, Aug 31, 2012 at 1:09 PM, Lachlan Musicman wrote: > Hi, > > I was just wondering if there was any noticeable difference between > the models.ChoiceField() and the mo

Model ChoiceField?

2012-08-30 Thread Lachlan Musicman
Hi, I was just wondering if there was any noticeable difference between the models.ChoiceField() and the models.CharField(max_length=x,)? In the documentation I have (offline, Django v1.4) a reference to: /path/django-docs-1.4-en/ref/forms/fields.html#django.forms.ChoiceField.choices But in the

Re: formeset choicefield dynamic choices

2012-08-08 Thread Melvyn Sopacua
On 8-8-2012 15:32, BiG-Up wrote: > I'm working on a formset with dynamic forms. I've overloaded my form > to be able to add new values in the select field but i cannot > overload the formset constructor. Django raise exception : > "__init__() takes exactly 1 argument (2 given)" formset.add_fields

formeset choicefield dynamic choices

2012-08-08 Thread BiG-Up
Hi, I'm working on a formset with dynamic forms. I've overloaded my form to be able to add new values in the select field but i cannot overload the formset constructor. Django raise exception : "__init__() takes exactly 1 argument (2 given)" - How can i change the way the formset_factory build

Re: how to get text of a ChoiceField populated with ajax

2012-05-23 Thread Kurtis Mullins
some more :) > > On Fri, May 18, 2012 at 2:57 AM, HDayi wrote: >> hi curtis, >> sorry for being so late. >> >> on the page i have given the url, it's told exactly how you said. I have >> subclassed djangos choicefield and just changed validatio

Re: how to get text of a ChoiceField populated with ajax

2012-05-23 Thread Kurtis Mullins
and I'll try to help some more :) On Fri, May 18, 2012 at 2:57 AM, HDayi wrote: > hi curtis, > sorry for being so late. > > on the page i have given the url, it's told exactly how you said. I have > subclassed djangos choicefield and just changed validation method that > al

Re: how to get text of a ChoiceField populated with ajax

2012-05-17 Thread HDayi
hi curtis, sorry for being so late. on the page i have given the url, it's told exactly how you said. I have subclassed djangos choicefield and just changed validation method that always return true. so my own clean_fieldname method started to work fine. I am checking the returned va

Re: how to get text of a ChoiceField populated with ajax

2012-05-09 Thread Kurtis Mullins
Hey, It would help a lot to see your code posted to dpaste.com or somewhere. As far as grabbing the choices in your clean method, here's a little copy-and-paste from Django's own ChoiceField so you can see how they do it: class ChoiceField(Field): > >

Re: how to get text of a ChoiceField populated with ajax

2012-05-09 Thread HDayi
hi again, finally i have solved the problem. I have found a web page saying you must create a custom choiceField class with a custom validation method. so i did that. http://blog.ikraftsoft.com/post/1342312823/django-form-choicefield-dynamic-values thx -- You received this message because

Re: how to get text of a ChoiceField populated with ajax

2012-05-09 Thread HDayi
hi Kurtis and Frances after populating the ChoiceField it looks like this First Second at first values were number but django form returns the value for this ChoiceField after validation. I don't have a clean_teacher method because i don't know what to do. i

Re: how to get text of a ChoiceField populated with ajax

2012-05-08 Thread Kurtis Mullins
s school list from database. the other is only a >> ChoiceField and it's empty. when school is chosen i populate the >> ChoiceField using dajax. it works perfectly but... >> >> while validating the form when calculating the cleaned_data value >> returns index of the se

Re: how to get text of a ChoiceField populated with ajax

2012-05-08 Thread francescortiz
have a form which has several selcet boxes. one is a > ModelChoiceField gets school list from database. the other is only a > ChoiceField and it's empty. when school is chosen i populate the > ChoiceField using dajax. it works perfectly but... > > while validating the form w

how to get text of a ChoiceField populated with ajax

2012-05-08 Thread HDayi
hi people, i am new to all of this. i have a form which has several selcet boxes. one is a ModelChoiceField gets school list from database. the other is only a ChoiceField and it's empty. when school is chosen i populate the ChoiceField using dajax. it works perfectly but... while valid

Re: ChoiceField Help

2012-01-29 Thread Daniel Roseman
On Saturday, 28 January 2012 21:41:13 UTC, Squant wrote: > > Hello, > I've created a simple ChoiceField for my app with two items. I need to > somehow query which choice was made from the user so I can pass the > appropriate context to my template. What would be an exampl

ChoiceField Help

2012-01-28 Thread Squant
Hello, I've created a simple ChoiceField for my app with two items. I need to somehow query which choice was made from the user so I can pass the appropriate context to my template. What would be an example of how I can do such a thing? Thanks! -- You received this message because yo

Re: How to use a DB table for choices=tuples in ChoiceField?

2012-01-27 Thread Leandro Ostera Villalva
hs later) >> >> >name 'scac_choicelist' is not defined at the marked >> >line in my form: >> > >> Which is true -- it is not defined at that point. (NOTE: your >> names >> don't really help understanding the purpose of the vari

Re: How to use a DB table for choices=tuples in ChoiceField?

2012-01-27 Thread Leandro Ostera Villalva
ving target for the few >> books that did come out to be relevant four months later) >> >> >name 'scac_choicelist' is not defined at the marked >> >line in my form: >> > >> Which is true -- it is not defined at that point. (NOTE: y

Re: How to use a DB table for choices=tuples in ChoiceField?

2012-01-21 Thread Bill Beal
ned at the marked > >line in my form: > > > Which is true -- it is not defined at that point. (NOTE: your names > don't really help understanding the purpose of the variables ) > > >from django import forms > >from django.forms.fields import ChoiceFi

Re: How to use a DB table for choices=tuples in ChoiceField?

2012-01-20 Thread Bill Beal
ur names > don't really help understanding the purpose of the variables ) > > >from django import forms > >from django.forms.fields import ChoiceField > >from myapp.models import * > > > >BOL_CODE_QUALIFIERS = ( > > ('OB', 'Ocean Bill of Ladi

Re: How to use a DB table for choices=tuples in ChoiceField?

2012-01-20 Thread Bill Beal
ill in the > "choices=" attribute for a ChoiceField in a form, > I could only find static sets of tuples for examples. > I need to use a table from the DB for the tuples. > I thought I could make up the choice list myself > from the table, but I'm getting a Name Error: &g

How to use a DB table for choices=tuples in ChoiceField?

2012-01-20 Thread Bill Beal
Hi All, When I looked in the docs for how to fill in the "choices=" attribute for a ChoiceField in a form, I could only find static sets of tuples for examples. I need to use a table from the DB for the tuples. I thought I could make up the choice list myself from the table, but I&#

Re: Newbie question on forms using ChoiceField and "choices" field...

2011-12-15 Thread Tom Evans
On Thu, Dec 15, 2011 at 8:27 PM, J. Marc Edwards wrote: > OK...I have the following model and form. > > class CmdString(models.Model): > >     name    = models.CharField(max_length=50) >     cmd = models.CharField(max_length=200) >     eda_app = models.OneToOneField(EDA_App, primary_key=True)

Newbie question on forms using ChoiceField and "choices" field...

2011-12-15 Thread J. Marc Edwards
OK...I have the following model and form. *class CmdString(models.Model): name= models.CharField(max_length=50) cmd = models.CharField(max_length=200) eda_app = models.OneToOneField(EDA_App, primary_key=True) def __unicode__(self): return self.cmd * *cl

Re: Choicefield in django

2011-11-10 Thread Michael P. Soulier
On 10/11/11 Asif Jamadar said: > Suppose I have choicefield in my django model which consist of several > choices. Now in future if I changed the existing choice (option) with some > other name (choice), then whether the existing records in model with that > choice(option) will als

Choicefield in django

2011-11-10 Thread Asif Jamadar
Suppose I have choicefield in my django model which consist of several choices. Now in future if I changed the existing choice (option) with some other name (choice), then whether the existing records in model with that choice(option) will also change? Or In admin page I need to set that new

Re: Onchange event on Choicefield in django formset

2011-11-02 Thread Kurtis Mullins
Whoops, sorry -- I didn't realize you weren't using CBVs. :) On Wed, Nov 2, 2011 at 12:43 PM, Furbee wrote: > I think your 'answer' is going to exist in POST in either case. Perhaps > change the construct of your logic to: > > if 'evaluation' in request.POST: > return render_to_respo

Re: Onchange event on Choicefield in django formset

2011-11-02 Thread Furbee
I think your 'answer' is going to exist in POST in either case. Perhaps change the construct of your logic to: if 'evaluation' in request.POST: return render_to_response('results.html') elif 'form-0-answer' in request.POST: answer = request.POST.get('answer','') val

Re: Onchange event on Choicefield in django formset

2011-11-02 Thread Kurtis Mullins
Try changing your success_url to this same page. On Wed, Nov 2, 2011 at 11:00 AM, asif.jama...@rezayat.net < asif.jama...@rezayat.net> wrote: > How can i access the form fields in django views. > > Suppose i have modelform called > > > class QuestionForm(forms.ModelForm): > > > answer = forms.Ch

Onchange event on Choicefield in django formset

2011-11-02 Thread asif.jama...@rezayat.net
How can i access the form fields in django views. Suppose i have modelform called class QuestionForm(forms.ModelForm): answer = forms.ChoiceField(choices=HAY_EVALUATION_CHOICES, widget=forms.Select(attrs={'onchange': 'this.form.submit();'})) In views.py if 'form-0-answer' in reque

Re: Django Form ChoiceField, initial not working

2010-12-11 Thread wayne
On Dec 11, 5:08 am, Sævar Öfjörð wrote: > I think you should provide your choices in the form field, not when > creating an instance of the form. Agreed. To create a dynamic form such as this, the best way would probably be to use a custom __init__ function. In your view, when you create your

Re: Django Form ChoiceField, initial not working

2010-12-11 Thread Sævar Öfjörð
I think you should provide your choices in the form field, not when creating an instance of the form. The form would then be something like this: class StoreLocationHoursForm(BForm): sl_list= [('-', 'Choose Location'), (u'Super City', u'901 PHILADELPHIA STREET')] location = forms.ChoiceFie

Django Form ChoiceField, initial not working

2010-12-09 Thread Sector7B
Hi, i have a simple form: class StoreLocationHoursForm(BForm): location = forms.ChoiceField(required=True) day = forms.ChoiceField(choices=bagit_constants.dow,required=True) time_open_hours = forms.ChoiceField(choices=constants.hours,required=True) time_open_minutes = forms.ChoiceFi

Re: Potential bug in [Typed]ChoiceField validation mechanism

2010-11-27 Thread ethereon
wrote: > In brief, a [Typed]ChoiceField can reject a valid choice of type > Decimal because it is incorrectly compared using smart_unicode. > Decimal('0.5')==Decimal('0.50') is true, while '0.5'=='0.50' is false. > > Verbosely, conside

Potential bug in [Typed]ChoiceField validation mechanism

2010-11-27 Thread ethereon
In brief, a [Typed]ChoiceField can reject a valid choice of type Decimal because it is incorrectly compared using smart_unicode. Decimal('0.5')==Decimal('0.50') is true, while '0.5'=='0.50' is false. Verbosely, consider a model defined like so : class

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread Shawn Milochik
On Sep 29, 2010, at 5:08 PM, aa56280 wrote: > Can't you specify the value using the initial argument? > http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial > > I did that originally, but it doesn't show up when the HiddenInput renders. That's why I stopped changing the widget. Sh

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread aa56280
Can't you specify the value using the initial argument? http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial On Sep 29, 3:33 pm, Shawn Milochik wrote: > Actually, I spoke too soon on this one. My original solution doesn't work > because the hidden input on the form doesn't have a valu

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread Shawn Milochik
Actually, I spoke too soon on this one. My original solution doesn't work because the hidden input on the form doesn't have a value, so the form won't validate. I fixed this by just adding display: none to the widget attrs in the __init__ instead of changing the widget to a HiddenInput. Now the

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread aa56280
That seems pretty straightforward me. You want to customize the form based on the user and so you're doing it when the form is initialized. Makes perfect sense. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread Shawn Milochik
I ran into an interesting forms issue today which I came up with a solution for. Now I'm wondering if there's a better way. Situation: I have a forms.Form with several fields in it, including a ChoiceField. The values in this ChoiceField are dependent on what the user has acces

ChoiceField -suppressing "Select a valid choice. That choice is not one of ..." error?

2010-09-21 Thread ydjango
How to suppress invalid_choice validation error for choicefield -"Select a valid choice. That choice is not one of ..." ? I am using a client side combo box where user can either select from the choices or add a new value. For new value Django - ChoiceField give invalid_choice valida

Re: Validation and dynamically extending ChoiceField choices

2010-08-17 Thread ringemup
Oh, that sounds like a great way to handle it. Thank you! On Aug 17, 10:10 am, Alex Robbins wrote: > Maybe the ChoiceField should just be a CharField that just uses the > Select widget class? That way it won't have choices hardcoded into the > field validation. Your clean meth

Re: Validation and dynamically extending ChoiceField choices

2010-08-17 Thread Alex Robbins
Maybe the ChoiceField should just be a CharField that just uses the Select widget class? That way it won't have choices hardcoded into the field validation. Your clean method could check that the domain is valid. Alex On Aug 16, 1:39 pm, ringemup wrote: > I have a domain search form

Validation and dynamically extending ChoiceField choices

2010-08-16 Thread ringemup
I have a domain search form with two fields: a Textarea for inputting a list of domains to check, and a ChoiceField for selecting a domain based on suggestions. The ChoiceField is required, and on the first submission is auto- populated with suggestions based on the domains listed in the textarea

Re: setting intial value for choicefield in admin panel

2010-07-26 Thread Condor Chou
On 7/26/10 4:08 AM, Daniel Roseman wrote: On Jul 26, 8:49 am, gondor wrote: I am using admin panel and using get_form to retrieve one of my table objects. I have a choicefield in this object but I don't know how to set the default. I have saw numerous examples of using the foll

Re: setting intial value for choicefield in admin panel

2010-07-26 Thread Daniel Roseman
On Jul 26, 8:49 am, gondor wrote: > I am using admin panel and using get_form to retrieve one of my table > objects.  I have a choicefield in this object but I don't know how to > set the default.   I have saw numerous examples of using the > following: > > class M

setting intial value for choicefield in admin panel

2010-07-26 Thread gondor
I am using admin panel and using get_form to retrieve one of my table objects. I have a choicefield in this object but I don't know how to set the default. I have saw numerous examples of using the following: class MyAdmin(admin.ModelAdmin): list_display = ('rank', 'n

Re: Set field value for ChoiceField

2010-05-03 Thread Thomas Allen
The field was being set correctly, but my template did not show this until now for some reason. Thomas On May 3, 5:34 pm, Thomas Allen wrote: > If I'm instantiating a form, how do I set a ChoiceField value in it? > > I have a form with an attribute "role" which I am

Set field value for ChoiceField

2010-05-03 Thread Thomas Allen
If I'm instantiating a form, how do I set a ChoiceField value in it? I have a form with an attribute "role" which I am setting to the user's current role, like so: form = EditUserForm({ 'last_name': user.last_name, 'first_name': user.fi

Re: Form with ChoiceField that collects additional info with each choice

2010-05-03 Thread derek
On Apr 30, 4:00 pm, gsnyder2007 wrote: > I'm looking for a pointer to sample code or advice regarding what is > the best way to build a form that allows the user to select from > several options and supply additional textual input that is associated > with the option they chose, e.g. > > choices =

Form with ChoiceField that collects additional info with each choice

2010-04-30 Thread gsnyder2007
I'm looking for a pointer to sample code or advice regarding what is the best way to build a form that allows the user to select from several options and supply additional textual input that is associated with the option they chose, e.g. choices = [ ('option1', 'value1'), # additional text inp

Re: ChoiceField Being Unpatriotic

2010-04-18 Thread ge...@aquarianhouse.com
Can you provide the source code? The error doesn't make sence. On Apr 18, 6:15 pm, amyhalf wrote: > Hi, thanks for the reply! > > I changed it to what you suggested but it's mad about something else, > now: > > TemplateSyntaxError > Caught an exception while rendering: 'ModelChoiceField' object

Re: ChoiceField Being Unpatriotic

2010-04-18 Thread amyhalf
Hi, thanks for the reply! I changed it to what you suggested but it's mad about something else, now: TemplateSyntaxError Caught an exception while rendering: 'ModelChoiceField' object has no attribute 'all' It's mad about how render it: {{ form.state }} I didn't read here (http://docs.djangopr

Re: ChoiceField Being Unpatriotic

2010-04-17 Thread ge...@aquarianhouse.com
try with: class AddressForm(forms.Form): first_and_last_name = forms.CharField(128, 1) street1 = forms.CharField(128, 1) street2 = forms.CharField(128, 1) city = forms.CharField(64, 1) state = forms.ModelChoiceField(queryset=States.objects.all()) form = Add

ChoiceField Being Unpatriotic

2010-04-17 Thread amyhalf
Hi, all! For the life of me I can't get anything to show up in a drop-down. Here's the model: class States(models.Model): id = models.IntegerField(unique = True, primary_key = True) abbrev = models.CharField(max_length = 2, blank = False) long_form = models.CharField(max_

Re: ChoiceField invalid literal for int() with base 10: ''

2010-04-15 Thread Nuno Maltez
Hi, I think the problem is tyhat you're using the wrong type of field in your form. A ChoiceField, like the documentations says [1], returns '' for an empty value, i.e. when you do not select an option. Trying to save an empty string into ans INT field in the database will thro

Re: ChoiceField invalid literal for int() with base 10: ''

2010-04-13 Thread geraldcor
That was a very good guess. I tried it but it didn't work. On Apr 13, 12:46 pm, johan sommerfeld wrote: >  You could try using initial=0. > > /J > > On Tuesday, April 13, 2010, geraldcor wrote: > > Hello all, > > > I know the error "invalid literal for int() with base 10: '' " has > > been discu

Re: ChoiceField invalid literal for int() with base 10: ''

2010-04-13 Thread johan sommerfeld
You could try using initial=0. /J On Tuesday, April 13, 2010, geraldcor wrote: > Hello all, > > I know the error "invalid literal for int() with base 10: '' " has > been discussed a lot in the past, but this seems to be unique to my > situation. > > I have 2 choice fields as defined below for b

Re: ChoiceField invalid literal for int() with base 10: ''

2010-04-13 Thread bfrederi
I happened to be stopping by to post my own question, and I don't know if this is the answer or not, but have you tried adding the argument blank=True to your model field? http://docs.djangoproject.com/en/dev/ref/models/fields/#blank -- You received this message because you are subscribed to the

ChoiceField invalid literal for int() with base 10: ''

2010-04-13 Thread geraldcor
Hello all, I know the error "invalid literal for int() with base 10: '' " has been discussed a lot in the past, but this seems to be unique to my situation. I have 2 choice fields as defined below for both the model and form: models.py class Checkin(models.Model): ... content = models.IntegerFie

Re: How to set a prompt for a choiceField?

2010-03-23 Thread Ivan Uemlianin
Very sorry everybody: I googled around tons, but I didn't search this group! LOL. I'll know next time. Adding an "invalid" choice to a ChoiceField? http://groups.google.com/group/django-users/browse_thread/thread/dd6d8eb11f915c94/77aa6fbea94af4c4?lnk=gst&q=choicefiel

How to set a prompt for a choiceField?

2010-03-23 Thread Ivan Uemlianin
Dear All I have a choiceField in one of my forms, and I'd like to have it rendered displaying a prompt. I think the html would be something like this: Please choose a colour: Red Green Blue This would display a drop-down menu showing "Pleas

Re: Default Selection in ChoiceField

2010-02-02 Thread Sumanth
Thanks guys Both work Sumanth On Feb 1, 11:09 pm, Shawn Milochik wrote: > You can do it in your view after creating the form, if you like. > > form = SomeForm() > form.fields['meal_pref'].initial = 2 > > Shawn -- You received this message because you are subscribed to the Google Groups "Djang

Re: Default Selection in ChoiceField

2010-02-01 Thread Shawn Milochik
You can do it in your view after creating the form, if you like. form = SomeForm() form.fields['meal_pref'].initial = 2 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. T

Re: Default Selection in ChoiceField

2010-02-01 Thread Rishabh Manocha
On Tue, Feb 2, 2010 at 8:56 AM, Sumanth wrote: > Hi all, > > I  have a basic form > > class AssumptionsForm(forms.Form): >       writedownoper  = forms.ChoiceField( required=True, choices = > [('1','1'),('2',2='),('3','3')]) > > Now in my view after I create the form I want to set value 2 as > def

Default Selection in ChoiceField

2010-02-01 Thread Sumanth
Hi all, I have a basic form class AssumptionsForm(forms.Form): writedownoper = forms.ChoiceField( required=True, choices = [('1','1'),('2',2='),('3','3')]) Now in my view after I create the form I want to set value 2 as default. How can I do it? Is there set default API that I can use.

Re: ChoiceField

2010-01-23 Thread pinco
have on the output. This it would be easy if I could output only and separately eg iterating through the single choices of the choicefield, instead of outputting all the ... block as a whole. By the way, thank you very much for your help. separately On Jan 22, 9:16 pm, Daniel Roseman wrote

Re: ChoiceField

2010-01-22 Thread Daniel Roseman
On Jan 21, 11:45 pm, pinco wrote: > The code > > {% for choice_value, choice_text in > myform.fields.choicefieldname.choices %} >                 choice_value: {{ choice_value }} >                 choice_text: {{ choice_text }} >                 {% endfor %} > > gives the choices text and values a

Re: ChoiceField

2010-01-21 Thread pinco
The code {% for choice_value, choice_text in myform.fields.choicefieldname.choices %} choice_value: {{ choice_value }} choice_text: {{ choice_text }} {% endfor %} gives the choices text and values associated to each choice, but actually do not rend

  1   2   3   >