how to implement multiple choices in model

2008-11-17 Thread Canhua
hi, I am trying to create such a kind of field in a model. The field can only take one or more values from a set of value, each seperated by such as commas. It seems that there is no built-in field type in Django. How may I implement this? Any clue is greatly appreciated. Best wishes Can-Hua

Re: custom query as the choices for dropdown

2008-11-05 Thread Rajesh Dhawan
Hi, > In the quest to build my web sales inventory system, I want to specify > that only stock that are available be listed in the dropdown. > > So my question is can I use a custom query to feed the choices for my field? Yes. See ModelChoiceField.queryset here: http://docs.djangopr

custom query as the choices for dropdown

2008-11-05 Thread Low Kian Seong
Dear all, In the quest to build my web sales inventory system, I want to specify that only stock that are available be listed in the dropdown. So my question is can I use a custom query to feed the choices for my field? Thank you. -- Low Kian Seong blog: http://lowkster.blogspot.com

Re: choices instantiation

2008-10-16 Thread [EMAIL PROTECTED]
Karen, Thank you. Based on your answer, I continued looking for problems in my code and in my setup. Firstly, the strings in the values of the choices were of length 7 and the CharField was of length 6. I was helped by a coworker to fix that. Then the problem of not showing the save'd choice

Re: Limit choices by object, not model

2008-10-16 Thread AmanKow
pe requested by the participant. Thus the foreign key to cert_types. However I need to limit the choices available to those in its associated activity. Hmm... now that I think about it, doesn't really seem doable, except in participations inlined with their activity, where the activity is known at

Re: Limit choices by object, not model

2008-10-16 Thread Ronny Haryanto
On Fri, Oct 17, 2008 at 12:23 AM, AmanKow <[EMAIL PROTECTED]> wrote: > I need to limit choices dynamically by an object, not a class: > When adding or changing a > participation object, either in the admin or via model forms, I need > to limit the choices for cert typ

Limit choices by object, not model

2008-10-16 Thread AmanKow
I need to limit choices dynamically by an object, not a class: class CertType(models.Model): name = models.CharField(max_length=128) class ActivityTopic(models.Model): cert_types = models.ManyToMany(CertType) class Participation(models.Model): activity_topic = models.ForeignKey

Re: choices instantiation

2008-10-16 Thread Karen Tracey
On Thu, Oct 16, 2008 at 1:43 AM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > hi, > > When I instance a ModelForm with a record of its base model, there is > a CharField with "choices" that doesn't show the stored value in the > combobox. Is this expected

choices instantiation

2008-10-15 Thread [EMAIL PROTECTED]
hi, When I instance a ModelForm with a record of its base model, there is a CharField with "choices" that doesn't show the stored value in the combobox. Is this expected behaviour? i'd like it to get instanced as if it were a ForeignKey best

Re: bug?: get_%s_display on CharField with choices (select field)

2008-10-10 Thread felix
On Oct 10, 3:08 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > I think I found a bug. > You have, but it's in your code, not Django. :-) brilliant :) yeah I wasn't entirely sure. it smelled like a bug. > If you look at ReleaseFeedback.get_rating_display at the > interactive prompt,

Re: bug?: get_%s_display on CharField with choices (select field)

2008-10-09 Thread Malcolm Tredinnick
On Thu, 2008-10-09 at 07:31 -0700, felix wrote: > bug?: get_%s_display on CharField with choices (select field) > > I think I found a bug. You have, but it's in your code, not Django. :-) > I'm using a select input type widget by passing in 'choices' to a > CharField > &

bug?: get_%s_display on CharField with choices (select field)

2008-10-09 Thread felix
bug?: get_%s_display on CharField with choices (select field) I think I found a bug. I'm using a select input type widget by passing in 'choices' to a CharField given: class ReleaseFeedback(models.Model): RATINGS = ( (1,'*'),(2,'**'),(3,'***'),(4,''),(5,'*') ) rating

Ticket #5737: "CheckboxSelectMultiple when you use choices, required=False is not respected" reappearing?

2008-10-02 Thread johnny
I found the same problem as ticket #5737. It was closed due to unable to reproduce it, but I am seeing the same problem. I have: class QueryForm(f.Form): status = f.ChoiceField(choices=STATUS_TYPES, widget=f.CheckboxSelectMultiple(), required=False) and the form validation errored

Re: How to dynamically set choices in ChoiceField

2008-09-30 Thread eswenson
I just ran into this myself, yesterday and found the solution by perusing the django source code. Your form class (MyClass) will have had a field called "fields" created by the meta class of the base form. That field will have a choices field that you can set. In your setChoice met

How to dynamically set choices in ChoiceField

2008-09-30 Thread alan
I'm having trouble dynamically assigning the choices to a ChoiceField. My ChoiceField stores an object's state. In the template pulldown for this field, I want to restrict the user to only go from stateA to StateB; from stateB to stateC, etc. Hence the allowable choices need to be a set based

Re: Custom attributes of RadioSelect widget choices

2008-09-29 Thread globophobe
your form's RadioSelect, i.e. book_type = forms.ChoiceField( choices = BOOKCHOICES, widget=forms.RadioSelect(renderer=RadioFieldRendererSubclass) ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Gro

Custom attributes of RadioSelect widget choices

2008-09-29 Thread davenaff
construct the form field, it looks like this: book_type = forms.ChoiceField( choices = BOOKCHOICES, widget=forms.RadioSelect(attrs={'onclick':'checkStatus(1)'}) ) And this makes the onclick attribute for every radio button the same. So, my questions are: 1. Can

Re: Cannot resolve keyword 'user' into field. Choices are: xxx, yyy, zzz

2008-09-29 Thread jim
Kool... that fixed it Thanks Jim On Sep 29, 1:23 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Mon, Sep 29, 2008 at 2:02 AM, jim <[EMAIL PROTECTED]> wrote: > > This gives me an error: > > Cannot resolve keyword 'user' into field. Choices are: xxx

Cannot resolve keyword 'user' into field. Choices are: xxx, yyy, zzz

2008-09-29 Thread jim
(): user_profile_obj = request.user.get_profile() ... This gives me an error: Cannot resolve keyword 'user' into field. Choices are: xxx, yyy, zzz Any ideas as to what may be causing this? Thanks Jim --~--~-~--~~~---~--~~ You received this message

Re: Cannot resolve keyword 'user' into field. Choices are: xxx, yyy, zzz

2008-09-29 Thread James Bennett
On Mon, Sep 29, 2008 at 2:02 AM, jim <[EMAIL PROTECTED]> wrote: > This gives me an error: > Cannot resolve keyword 'user' into field. Choices are: xxx, yyy, zzz > > Any ideas as to what may be causing this? Your profile model must have a ForeignKey or a OneToOneFiel

Re: Cannot resolve keyword 'user' into field. Choices are: xxx, yyy, zzz

2008-09-29 Thread Daniel Roseman
): > >    if request.method == 'POST': >       pass >    else: >       if request.user.is_authenticated(): >          user_profile_obj = request.user.get_profile() >          ... > > This gives me an error: > Cannot resolve keyword 'user' into field. Choices are: xxx,

Re: Schema Evolution Choices?

2008-09-01 Thread Russell Keith-Magee
On Tue, Sep 2, 2008 at 12:37 AM, Jon Loyens <[EMAIL PROTECTED]> wrote: > > Hi guys, > > I have a small project coming up that I think having some sort of > schema evolution facilities will be handy on. I was wondering what > the current and best project choices for

Schema Evolution Choices?

2008-09-01 Thread Jon Loyens
Hi guys, I have a small project coming up that I think having some sort of schema evolution facilities will be handy on. I was wondering what the current and best project choices for schema evolution are? I was leaning towards django-evolution until I saw a post from Russell saying that he

Re: limiting choices in admin.ModelAdmin based on request.user

2008-09-01 Thread Nick Day
Thanks! :) Nick On Sep 1, 3:18 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Sep 1, 2:53 pm, Nick Day <[EMAIL PROTECTED]> wrote: > > > Would somebody be able to provide a simple example of using get_form() > > within the ModelAdmin to retrieve the currently logged-in user? > > > Thanks in

Re: limiting choices in admin.ModelAdmin based on request.user

2008-09-01 Thread Daniel Roseman
On Sep 1, 2:53 pm, Nick Day <[EMAIL PROTECTED]> wrote: > Would somebody be able to provide a simple example of using get_form() > within the ModelAdmin to retrieve the currently logged-in user? > > Thanks in advance, > Nick > Not difficult: class MyAdmin(admin.ModelAdmin): def

Re: limiting choices in admin.ModelAdmin based on request.user

2008-09-01 Thread Nick Day
is it possible to limit choices on a website (not using > ModelAdmin)? > > thanks, > patrick > > On Aug 25, 9:35 am, krylatij <[EMAIL PROTECTED]> wrote: > > > > There is no longer any reason whatsoever to use this in any way in the > > > admin.

Re: limiting choices in admin.ModelAdmin based on request.user

2008-08-26 Thread patrickk
can someone provide an example for this? moreover, how is it possible to limit choices on a website (not using ModelAdmin)? thanks, patrick On Aug 25, 9:35 am, krylatij <[EMAIL PROTECTED]> wrote: > > There is no longer any reason whatsoever to use this in any way in t

Re: limiting choices in admin.ModelAdmin based on request.user

2008-08-25 Thread krylatij
> There is no longer any reason whatsoever to use this in any way in the > admin. It was an ugly, fragile hack before and it's unnecessary now > because ModelAdmin has a get_form() method -- which receives the > HttpRequest object as an argument -- that you can override to tweak > the form on a

Re: limiting choices in admin.ModelAdmin based on request.user

2008-08-25 Thread James Bennett
2008/8/25 krylatij <[EMAIL PROTECTED]>: > You can use ThreadLocals middleware > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > to get current user No. There is no longer any reason whatsoever to use this in any way in the admin. It was an ugly, fragile hack before and it's

Re: limiting choices in admin.ModelAdmin based on request.user

2008-08-25 Thread krylatij
On 24 авг, 23:56, "Patrick J. Anderson" <[EMAIL PROTECTED]> wrote: > How should I limit choices for ForeignKey fields in admin.ModelAdmin > instances based on request.user attributes, since I can't pass a request > object to the forms.ModelForm constructor? You can us

limiting choices in admin.ModelAdmin based on request.user

2008-08-24 Thread Patrick J. Anderson
How should I limit choices for ForeignKey fields in admin.ModelAdmin instances based on request.user attributes, since I can't pass a request object to the forms.ModelForm constructor? --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: limit choices to logged-in user

2008-08-20 Thread Erik Allik
ite. >> >> thanks, >> patrick >> >> On Aug 19, 5:48 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote: >> >>>> -Original Message- >>>> From: django-users@googlegroups.com >>>> [mailto:[EMAIL PR

Re: limit choices to logged-in user

2008-08-19 Thread brentp
rs@googlegroups.com > > > [mailto:[EMAIL PROTECTED] On Behalf Of patrickk > > > Sent: 19 August 2008 14:12 > > > To: Django users > > > Subject: limit choices to logged-in user > > > > is there a way to limit choices (using foreign key) to the >

Re: limit choices to logged-in user

2008-08-19 Thread patrickk
the functionality of the site. thanks, patrick On Aug 19, 5:48 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: django-users@googlegroups.com > > [mailto:[EMAIL PROTECTED] On Behalf Of patrickk > > Sent: 19 August 2008 14:12 > &g

RE: limit choices to logged-in user

2008-08-19 Thread Emily Rodgers
> -Original Message- > From: django-users@googlegroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of patrickk > Sent: 19 August 2008 14:12 > To: Django users > Subject: limit choices to logged-in user > > > is there a way to limit choices (using foreign ke

limit choices to logged-in user

2008-08-19 Thread patrickk
is there a way to limit choices (using foreign key) to the logged-in user? I´ve tried limit_choices_to = {'user': request.user}, but that is obviously not working since "request" is not available. any ideas? thanks, patrick --~--~-~--~~~---~--~~ Yo

Re: Defaults with "choices"

2008-07-04 Thread Malcolm Tredinnick
On Fri, 2008-07-04 at 18:28 -0700, Leaf wrote: > I'm working on an app called Dj Styles. It generates stylesheets > dynamically. Anyway, I'm laying out the Style model, and I need to > know: If you're using the "choices" parameter on a CharField, then > which do yo

Defaults with "choices"

2008-07-04 Thread Leaf
I'm working on an app called Dj Styles. It generates stylesheets dynamically. Anyway, I'm laying out the Style model, and I need to know: If you're using the "choices" parameter on a CharField, then which do you put for the "default" parameter - the value that gets reco

Re: choices

2008-07-03 Thread rskm1
On Jul 3, 8:13 am, urukay <[EMAIL PROTECTED]> wrote: > no, no i mean it otherway, just like Rajesh Dhawan wrote (link he sent). I will rephrase your original question; it's not obvious to everyone that the REASON you want two of your six choices to be "not selectab

Re: choices

2008-07-03 Thread urukay
) and I need the user to chose only >> one >> option from the list. Just can't count on that user wil chose to fill >> only >> one field with choices if there are more possible fields with choices. >> And it isn't possible to add to oe field multiple choices lists

Re: choices

2008-07-03 Thread Alessandro Ronchi
2008/7/3, urukay <[EMAIL PROTECTED]>: > > > yes, but it's only for limpidity :) and I need the user to chose only one > option from the list. Just can't count on that user wil chose to fill only > one field with choices if there are more possible fields with choices. >

Re: choices

2008-07-03 Thread urukay
yes, but it's only for limpidity :) and I need the user to chose only one option from the list. Just can't count on that user wil chose to fill only one field with choices if there are more possible fields with choices. And it isn't possible to add to oe field multiple choices lists (i mena

Re: choices

2008-07-02 Thread Malcolm Tredinnick
On Wed, 2008-07-02 at 13:40 -0700, urukay wrote: > > is there a way how to create choices in Models in specific way, that some > choices are not selectable (they only group and describe choices below)? > > e.g.: > > CHOICES = ( > ('0', 'Basic Colors'), >

Re: choices

2008-07-02 Thread urukay
thanks, but i was wondering if it's possible to do that in MODEL? Rajesh Dhawan wrote: > > > > > On Jul 2, 4:40 pm, urukay <[EMAIL PROTECTED]> wrote: >> is there a way how to create choices in Models in specific way, that some >> choices are not selecta

Re: choices

2008-07-02 Thread Rajesh Dhawan
On Jul 2, 4:40 pm, urukay <[EMAIL PROTECTED]> wrote: > is there a way how to create choices in Models in specific way, that some > choices are not selectable (they only group and describe choices below)? > > e.g.: > > CHOICES = ( >      ('0', 'Basic Colors'), >

choices

2008-07-02 Thread urukay
is there a way how to create choices in Models in specific way, that some choices are not selectable (they only group and describe choices below)? e.g.: CHOICES = ( ('0', 'Basic Colors'), ('1', 'Red'), ('2', 'Green'), ('3', 'Blue'), ('4', 'Other Colors'), ('5

Re: dynamic choices for views/newforms

2008-06-29 Thread John Aherne
Daniel Roseman wrote: > On Jun 29, 2:24 pm, John Aherne <[EMAIL PROTECTED]> wrote: > >> OK. I did some more experimenting with ModelChoiceField and my table. >> >> Surprise. It worked when I thought it would not. Why did it work. By >> luck in my model I had the __unicode__ function return the

Re: dynamic choices for views/newforms

2008-06-29 Thread Daniel Roseman
On Jun 29, 2:24 pm, John Aherne <[EMAIL PROTECTED]> wrote: > OK. I did some more experimenting with ModelChoiceField and my table. > > Surprise. It worked when I thought it would not. Why did it work. By > luck in my model I had the __unicode__ function return the right value. > So now I could

Re: dynamic choices for views/newforms

2008-06-29 Thread John Aherne
ist filled. Once again my model >>> has 10 fields, but I only want to get 2 of those to use in my selection >>> list. >>> >>> I thought about filling out a dictionary and passing that in as per the >>> samples in forms.py. But I then read that I should not be

Re: dynamic choices for views/newforms

2008-06-29 Thread John Aherne
sion data. At the moment, I'm >> not using session data, I just want to hardcode the options so I can >> concentrate on how I get my selection list filled. Once again my model >> has 10 fields, but I only want to get 2 of those to use in my selection >> list. >> >&

Re: dynamic choices for views/newforms

2008-06-29 Thread Daniel Roseman
rate on how I get my selection list filled. Once again my model > has 10 fields, but I only want to get 2 of those to use in my selection > list. > > I thought about filling out a dictionary and passing that in as per the > samples in forms.py. But I then read that I should not be do

dynamic choices for views/newforms

2008-06-29 Thread John Aherne
filling out a dictionary and passing that in as per the samples in forms.py. But I then read that I should not be doing this. Choices in forms is for mainly static selections. So I then start looking for a way to get my data set up for a selection list. But as I say, I've looked

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-20 Thread Huuuze
You da man. This worked perfectly out of the box. Thank you! On Jun 19, 5:54 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > On Jun 19, 3:45 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > > >                 if self.instance.state == 'processing': > >                     queryset =

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Nathaniel Whiteinge
On Jun 19, 3:45 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: >                 if self.instance.state == 'processing': >                     queryset = queryset.exclude(state='new') The above lines aren't quite right ``self.instance`` is an instance of your ``SomeModel`` and presuming

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Nathaniel Whiteinge
On Jun 19, 3:23 pm, Huuuze <[EMAIL PROTECTED]> wrote: > In this example, what if you wanted to selectively remove a value from > the choice list. For that you'll have to move the field declaration into the form's __init__ method:: class SomeForm(forms.ModelForm): class Meta:

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-19 Thread Huuuze
In this example, what if you wanted to selectively remove a value from the choice list. For example, let's say the list contained New, In Process, and Closed. When an item is "In Process", it cannot revert back to "New". As such, "New" should not be displayed amon

Re: Limiting the choices of ForeignKey objects in the admin filters

2008-06-18 Thread moonsand
Hmm I would also be interested if anyone knows how to do this. On Jun 17, 3:05 pm, mbdtsmh <[EMAIL PROTECTED]> wrote: > Hello everyone, > > I have a question for you all that has been discussed before but I > cannot figure out the best way to go about implementing. > > I have the following

Limiting the choices of ForeignKey objects in the admin filters

2008-06-17 Thread mbdtsmh
Hello everyone, I have a question for you all that has been discussed before but I cannot figure out the best way to go about implementing. I have the following model: class DesignSet(models.Model): priority=models.ForeignKey(Priority) status=models.ForeignKey(Status,

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-08 Thread Berco Beute
Great! A cleaner solution. Thanks! Is there any effort underway for making overriding default widgets simpler? I think that's really needed (especially for beginner like me). 2B On Jun 8, 1:20 am, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > On Jun 7, 4:18 pm, Berco Beute <[EMAIL

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-07 Thread Nathaniel Whiteinge
On Jun 7, 4:18 pm, Berco Beute <[EMAIL PROTECTED]> wrote: > Quite a lot of work for something so simple I agree that overriding default widgets is currently too much work. But here's a slightly shorter version that works in exactly the same way as your example:: class

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-05 Thread Nathaniel Whiteinge
On Jun 5, 7:36 am, Berco Beute <[EMAIL PROTECTED]> wrote: > My model has a ForeignKey that renders as a SELECT field in HTML. The > problem is that there's an empty value ('-') that I would like > to hide. Presuming you are using newforms (i.e. not the Admin), then override the

Remove empty value ('---------') from HTML SELECT choices

2008-06-05 Thread Berco Beute
My model has a ForeignKey that renders as a SELECT field in HTML. The problem is that there's an empty value ('-') that I would like to hide. I've tried adding 'null=False' and 'blank=False' to the ForeignKey but the empty value still appears. Any suggestions? 2B

Re: IntegerField with choices raising an TypeError

2008-05-22 Thread Jashugan
In the meantime I did the following: def save(self): try: self.score = int(self.score) except: pass super(Entry, self).save() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: IntegerField with choices raising an TypeError

2008-05-22 Thread Jashugan
On May 22, 6:29 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > I suspect your problem may be due to the fact that your display value for 3 > is a number rather than a string.  Try changing: > >    CHOICES = [(1, '1'), (2, '2'), (3, 3), (4, '4'), (5, '5')] > >

Re: IntegerField with choices raising an TypeError

2008-05-22 Thread Scott Moonen
I suspect your problem may be due to the fact that your display value for 3 is a number rather than a string. Try changing: CHOICES = [(1, '1'), (2, '2'), (3, 3), (4, '4'), (5, '5')] to CHOICES = [(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5')] -- Scott On Wed, May 21, 2008 at 7

Re: IntegerField with choices raising an TypeError

2008-05-22 Thread Adi J. Sieker
Jashugan wrote: > Hello I have the following code in my model: > > class SomeMode(models.Model): > > CHOICES = [(1, '1'), (2, '2'), (3, 3), (4, '4'), (5, '5')] > > score = models.IntegerField(choices=CHOICES) > > > When I change the score in the admin

IntegerField with choices raising an TypeError

2008-05-21 Thread Jashugan
Hello I have the following code in my model: class SomeMode(models.Model): CHOICES = [(1, '1'), (2, '2'), (3, 3), (4, '4'), (5, '5')] score = models.IntegerField(choices=CHOICES) When I change the score in the admin interface it throws this error: an integer is required I think

Re: Using ModelForm...not populating my choices

2008-05-20 Thread AdamG
ocs are somewhat incomplete - they only explain > how to set the initial queryset. I've been meaning to write up some > documentation explaining the .queryset attribute, so thanks for > spurring some action :) > > Adam > > On Tue, May 20, 2008 at 8:59 AM, chylld <[EMAIL PROTECTED]>

Re: Using ModelForm...not populating my choices

2008-05-20 Thread Adam Gomaa
have exactly the same problem; I just want to fill the ChoiceField > with a certain subset of choices based on the current user. Have you > found a way to do this?? > > Jonathan > > > On Apr 10, 7:21 am, ydjango <[EMAIL PROTECTED]> wrote: >> Yes, They are defined

Re: Using ModelForm...not populating my choices

2008-05-20 Thread chylld
I have exactly the same problem; I just want to fill the ChoiceField with a certain subset of choices based on the current user. Have you found a way to do this?? Jonathan On Apr 10, 7:21 am, ydjango <[EMAIL PROTECTED]> wrote: > Yes, They are defined in model as > > owner = mo

Re: two choices questions

2008-04-29 Thread dimrub
the field's _choices property with the options sorted to my liking. I can provide the necessary code samples, if anyone is interested. On Apr 25, 11:57 pm, dimrub <[EMAIL PROTECTED]> wrote: > 2. Is there a way to sort the order of the choices dynamically (e.g., > based on the current us

Re: two choices questions

2008-04-25 Thread dimrub
imrub <[EMAIL PROTECTED]> wrote: > Greetings, all! > > Two (possibly - trivial) questions regarding a field that has > 'choices' defined for it. > > 1. Is there a way to specify a special choice, upon which another > field becomes active? A typical use case is to have a certain

Re: two choices questions

2008-04-25 Thread dimrub
On Apr 25, 11:57 pm, dimrub <[EMAIL PROTECTED]> wrote: > Greetings, all! > Oh, forgot to mention: I'm trying to use admin views. I do realize question #2 has a trivial solution if a non-admin view is used (and, come to think of it, #1 does as well).

two choices questions

2008-04-25 Thread dimrub
Greetings, all! Two (possibly - trivial) questions regarding a field that has 'choices' defined for it. 1. Is there a way to specify a special choice, upon which another field becomes active? A typical use case is to have a certain set of predefined values (out of which the user will USUALLY

Re: ModelForm, Foreign key and blank value in choices

2008-04-18 Thread Phil Davis
setting it to a value existing in > a related model doesn't help me to get rid of blank value. > > Is there any way to do that, other than manually generating choices: > In AnObjectForm's __init__: > > self.fields['object_category'].widget = > forms.RadioSel

ModelForm, Foreign key and blank value in choices

2008-04-17 Thread eXt
ially selected instead)." Blank is True and default doesn't make sense here... but even setting it to a value existing in a related model doesn't help me to get rid of blank value. Is there any way to do that, other than manually generating choices: In AnObjectForm's __init__: s

Re: Dynamically limiting choices in admin.

2008-04-15 Thread Justin Bronn
Rodrigo, I've found this to be a common use-case among many projects of mine. The admin becomes completely unusable if you have hundreds of thousands of possibilities for ForeignKey and/or ManyToMany relations. I've created a `ModelAdmin` (newforms-admin) subclass called `LimitedRelatedAdmin`

Re: Dynamically limiting choices in admin.

2008-04-14 Thread Rodrigo Culagovski
Richard, I see your point, but there could be many, many issues for each magazine, and over a hundred magazines total, so I don't want to make the users wade through a few thousand issues each time. I'd like to be able to drill down, first pick a magazine, then one of its issues. What I'm

Re: Dynamically limiting choices in admin.

2008-04-14 Thread Richard Dahl
This is where I would suggest you rethink your data model. Is there a reason to link Article to both Issues and Magazine? Why not something like: Issues has FK (magazine) to Magazine Articles has FK (issue) to Issues Issues could be configured to return its magazine.title and self.issue_number

Dynamically limiting choices in admin.

2008-04-14 Thread Rodrigo Culagovski
I have 3 models: Magazine, Issue and Article. Each Magazine has 1 or more Issues and each Issue has 1 or more Articles. Article has models.ForeignKey(Issue) and models.ForeignKey(Magazine). Issue has models.ForeignKey(Magazine)). In the admin, when creating a new article, I choose which Magazine

Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-11 Thread Rishabh Manocha
lf a few hours > > > of pulling my hair out. > > > > > Best, > > > > > ROn Wed, Apr 9, 2008 at 11:19 PM, Justin <[EMAIL PROTECTED]> wrote: > > > > > > I noticed when looking at some code that after setting the queryset, > >

Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-10 Thread Justin
> it appears in the form. I can call ._get_queryset() or .queryset and > > > it looks updated. > > > > The problem occurs in the actual form rendered. > > > > form.as_ul() does not have the updated choices for the checkbox. I'm > > > digging through

Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-10 Thread Justin
nd > > it looks updated. > > > The problem occurs in the actual form rendered. > > > form.as_ul() does not have the updated choices for the checkbox. I'm > > digging through django code but still nothing. > > > On Apr 8, 11:05 pm, Justin <[EMAIL PROTECTED]&g

Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-10 Thread Rishabh Manocha
ul() does not have the updated choices for the checkbox. I'm > digging through django code but still nothing. > > > > On Apr 8, 11:05 pm, Justin <[EMAIL PROTECTED]> wrote: > > I have a form: > > > > class TestForm(forms.Form): > >

Re: Using ModelForm...not populating my choices

2008-04-09 Thread James Bennett
On Wed, Apr 9, 2008 at 4:21 PM, ydjango <[EMAIL PROTECTED]> wrote: > owner = models.ForeignKey(Participant,null=True) Not the *model* fields, the *form* fields for representing this type of relationship. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct."

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
Yes, They are defined in model as owner = models.ForeignKey(Participant,null=True) all I want is to display only the Partcipants for a particular group in the choice field ( not all participants) and I am so frustrated now. eg. Participant.objects.filter(group__exact=my_group)] thanks Ashish

Re: Using ModelForm...not populating my choices

2008-04-09 Thread James Bennett
On Wed, Apr 9, 2008 at 3:30 PM, ydjango <[EMAIL PROTECTED]> wrote: > Miles and Owner are defined as foreign_key to respective tables. Yes, but did you actually look at the docs for the field types that make it easy to represent foreign keys? -- "Bureaucrat Conrad, you are technically correct

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
e tried everything in code below, passing choices , queryset, > changing to choicefield etc. It just ignores everything and gets data > from __unicode_ function for the foreign key table - all rows. ( > I am learning Python through Django, so may be I am making some python > newbie mis

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
for Miles, owner, All I need is subset of data. I have tried everything in code below, passing choices , queryset, changing to choicefield etc. It just ignores everything and gets data from __unicode_ function for the foreign key table - all rows. ( I am learning Python through Django, so may

Re: Using ModelForm...not populating my choices

2008-04-09 Thread James Bennett
On Wed, Apr 9, 2008 at 2:56 PM, ydjango <[EMAIL PROTECTED]> wrote: > Not for model form, if a ChoiceField is based on foreign Key. It is > getting values from the referenced table using the __unicode__ method > in that table and ignoring the choices field passed to it. N

Re: Using ModelForm...not populating my choices

2008-04-09 Thread ydjango
Not for model form, if a ChoiceField is based on foreign Key. It is getting values from the referenced table using the __unicode__ method in that table and ignoring the choices field passed to it. On Mar 27, 7:57 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Thu, Mar

Re: ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-09 Thread Justin
I noticed when looking at some code that after setting the queryset, it appears in the form. I can call ._get_queryset() or .queryset and it looks updated. The problem occurs in the actual form rendered. form.as_ul() does not have the updated choices for the checkbox. I'm digging through

ModelMultipleChoiceField updating HTML choices after 2nd reload

2008-04-08 Thread Justin
Task.objects.none(). If I hit F5 to reload, the correct tasks based on the project show up. I can hit F5 infinitely and it's correct. It's only on that first load. More weird... I click back out to a different project page. When I click the link, I expect it to show the form with a new set o

Re: Using ModelForm...not populating my choices

2008-03-27 Thread Greg
ed in my template as Radio Buttons. So I > > added the line ' experience = > > forms.CharField(widget=forms.RadioSelect) ' to my ModelClass. > > However, when I do this then my SATISFACTION choices don't get > > displayed in my template. > > > My Models File > &g

Re: Using ModelForm...not populating my choices

2008-03-27 Thread Brian Armstrong
ttons. So I > added the line ' experience = > forms.CharField(widget=forms.RadioSelect) ' to my ModelClass. > However, when I do this then my SATISFACTION choices don't get > displayed in my template. > > My Models File > > SATISFACTION = ( > ('1', 'Agree'),('2',

Using ModelForm...not populating my choices

2008-03-27 Thread Greg
. However, when I do this then my SATISFACTION choices don't get displayed in my template. My Models File SATISFACTION = ( ('1', 'Agree'),('2', 'Disagree'), ) class Survey(models.Model): experience = models.CharField(max_length=100, choices=SATISFACTION) My ModelForm class class

Re: reason to limit choices actual-value length?

2008-02-10 Thread Malcolm Tredinnick
On Mon, 2008-02-04 at 11:22 -0800, [EMAIL PROTECTED] wrote: > I'm talking about this kind of choices field > http://www.djangoproject.com/documentation/model-api/#choices > > e.g. > class Foo(models.Model): > GENDER_CHOICES = ( > ('M', 'Male'), &g

Re: reason to limit choices actual-value length?

2008-02-04 Thread Rajesh Dhawan
>     ) >     gender = models.CharField(max_length=1, choices=GENDER_CHOICES) > > Is there a reason to not mirror the actual value stored with the human > readable one? Are you buying much by having a single character rather > than around 20 or 30? Right..you should see no p

reason to limit choices actual-value length?

2008-02-04 Thread [EMAIL PROTECTED]
I'm talking about this kind of choices field http://www.djangoproject.com/documentation/model-api/#choices e.g. class Foo(models.Model): GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) gender = models.CharField(max_length=1, choices=GENDER_CHOICES

Re: How to use newforms ChoiceField to show dynamic choices

2008-01-25 Thread ikks
I have mod_python and I'm using ModelChoiceField, but I'm not getting the expected results, when I change my queryset and the second has elements not present on the original queryset, it displays the choices but doesn't validate properly, complaining about the option not being valid for the set

<    1   2   3   4   5   6   7   8   9   >