Dynamic Choices for ChoiceField

2009-07-31 Thread mviamari
the choices parameter in the ChoiceField declaration to be derived from a query result from SQLAlchemy (returned as an array of tuples). The problem is that the choices don't update when the database changes. They are fixed to whatever was present when the server is initialized (or at least it appears

Re: django profiles :: choices form?

2009-07-21 Thread Saketh
s > > models.py > > class Foo(models.Model): >GENDER_CHOICES = ( >('M', 'Male'), >('F', 'Female'), >) > gender = models.CharField(max_length=1, choices=GENDER_CHOICES) > > > On Jul 20, 11

Re: django profiles :: choices form?

2009-07-21 Thread Léon Dignòn
= models.CharField(max_length=1, choices=GENDER_CHOICES) On Jul 20, 11:24 pm, Saketh <saketh.bhamidip...@gmail.com> wrote: > Hi everyone, > > I am making a user settings page for my application based on django- > registration and django-profiles, but I'm running into a small problem

django profiles :: choices form?

2009-07-20 Thread Saketh
Hi everyone, I am making a user settings page for my application based on django- registration and django-profiles, but I'm running into a small problem in how I'd like the page to be laid out. My data model has a field that can take on only three values, 'A', 'B', and 'C'. I have modeled this

Re: SelectMultiple with Static Choices in admin Interface

2009-07-13 Thread Ian Clelland
On Jul 13, 10:03 am, itodd <tohh...@gmail.com> wrote: > Greetings, > > I'm trying to use a SelectMultiple with a set of static choices. I'm > experiencing odd behavior when the number of choices exceeds 10. For > example, take the following Model and ModelForm: > >

SelectMultiple with Static Choices in admin Interface

2009-07-13 Thread itodd
Greetings, I'm trying to use a SelectMultiple with a set of static choices. I'm experiencing odd behavior when the number of choices exceeds 10. For example, take the following Model and ModelForm: class Project(models.Model): RECIPIENTS = ( (1,'Brad'), (2,'Fred

attrs for all choices in choicefield

2009-07-10 Thread virhilo
Hi I have that choice field: RATES = ( ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ) rating = forms.ChoiceField(widget=forms.RadioSelect(), required=True, choices=RATES) Now - how to assign attrs for all choices(for example apply css

Re: Limiting the choice of ChoiceField if not in choices

2009-07-09 Thread urukay
Hi, how does your view looks like? why you're unable to set initial data for the form? Radovan firebug wrote: > > > Hi, > > I want to limit the choice of ChoiceField to a predefined value, if > the value from POST does not exist in given choices. How this could be >

Limiting the choice of ChoiceField if not in choices

2009-07-09 Thread firebug
Hi, I want to limit the choice of ChoiceField to a predefined value, if the value from POST does not exist in given choices. How this could be done easily? I don't want to modify the POST-dictionary before it is passed to the form instance, because I would have to write same code all over

Re: Retrieving nested choices.

2009-07-06 Thread Magnus Valle
Alex Gaynor wrote: > > > On Tue, Jul 7, 2009 at 12:16 AM, Magnus Valle <li...@negativehalf.com > <mailto:li...@negativehalf.com>> wrote: > > > I have a CharField model with nested choices, like this one: > > MEDIA_CHOICES = ( >('A

Re: Retrieving nested choices.

2009-07-06 Thread Alex Gaynor
On Tue, Jul 7, 2009 at 12:16 AM, Magnus Valle <li...@negativehalf.com>wrote: > > I have a CharField model with nested choices, like this one: > > MEDIA_CHOICES = ( >('Audio', ( >('vinyl', 'Vinyl'), >('cd', 'CD'), >) >), &g

Retrieving nested choices.

2009-07-06 Thread Magnus Valle
I have a CharField model with nested choices, like this one: MEDIA_CHOICES = ( ('Audio', ( ('vinyl', 'Vinyl'), ('cd', 'CD'), ) ), ('Video', ( ('vhs', 'VHS Tape'), ('dvd', 'DVD'), ) ), ('unknown', 'Unknown

Re: Why is (db) Field.form_class hardcoded to TypedChoiceField if field has choices?

2009-06-25 Thread Flo Ledermann
I am sorry folks, I just found the corresponding issue: http://code.djangoproject.com/ticket/9245 however, i would still be interested in discussing the reasons behind this - and why the patch provided in the ticket did't get applied yet ;) flo

Why is (db) Field.form_class hardcoded to TypedChoiceField if field has choices?

2009-06-25 Thread Flo Ledermann
Hi all, I am trying to implement a "FlagField" that can be used to store binary flags in a single integer value in the DB. The approach that looks most promising is subclassing Integer Field, pass in some choices as possible flags (which will be internally converted into the appropriat

Re: inline model's choices field empty in admin

2009-06-02 Thread ryan
Thank you sir. I got this from "Python Web Dev. w/ Django". An unforseen side effect. ryan On Jun 2, 12:05 pm, Daniel Roseman <roseman.dan...@googlemail.com> wrote: > On Jun 2, 4:53 pm, ryan <writepyt...@gmail.com> wrote: > > > This additional model, which

Re: inline model's choices field empty in admin

2009-06-02 Thread Daniel Roseman
On Jun 2, 4:53 pm, ryan <writepyt...@gmail.com> wrote: > This additional model, which uses the same choices is emptying the > choices dropdown of both User with inline UserProfile and UserProfile > itself.  Add it prior to UserProfile in models.py of your test app: > > clas

Re: inline model's choices field empty in admin

2009-06-02 Thread ryan
This additional model, which uses the same choices is emptying the choices dropdown of both User with inline UserProfile and UserProfile itself. Add it prior to UserProfile in models.py of your test app: class Person(models.Model): sales_team = models.IntegerField(choices=SALES_TEAM_CHOICES

Re: inline model's choices field empty in admin

2009-06-02 Thread Karen Tracey
On Tue, Jun 2, 2009 at 10:59 AM, ryan <writepyt...@gmail.com> wrote: > > When I edit a User in the admin, the sales_team and user_class > dropdowns are empty. > > If anyone can point out my error or point me to the django core code > that ignores the choices, I

inline model's choices field empty in admin

2009-06-02 Thread ryan
When I edit a User in the admin, the sales_team and user_class dropdowns are empty. If anyone can point out my error or point me to the django core code that ignores the choices, I would greatly appreciate it. #models.py SALES_TEAM_CHOICES = enumerate(('CLS','CCS','TPS')) USER_CLASS_CHOICES

Re: setting choices on choice field dynamically according to objects current state

2009-05-27 Thread Simon Davies
Thanks v What you said echoes what I found on a posting on djangosnippet.org about populating the choices in the init field. It works fine now. On May 26, 9:30 am, V <viktor.n...@gmail.com> wrote: > On May 25, 1:27 pm, Simon Davies <simon...@gmail.com> wrote: > > > &g

Re: setting choices on choice field dynamically according to objects current state

2009-05-26 Thread V
On May 25, 1:27 pm, Simon Davies <simon...@gmail.com> wrote: > I have a choices field called status in my model form which can be set > to a number of values, however the options available will be based on > its current state something like this, so it needs to refer to it

setting choices on choice field dynamically according to objects current state

2009-05-25 Thread Simon Davies
I have a choices field called status in my model form which can be set to a number of values, however the options available will be based on its current state something like this, so it needs to refer to itself: class ContractForm(ModelForm): def getStatusChoices() if status == 'r

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Sam Chuparkoff
On Sun, 2009-05-17 at 20:01 -0700, Bobby Roberts wrote: > yeah i'm still lost... You don't need to change your form, just use form.cleaned_data in your view. Same example, a few more lines: >>> # our form ... >>> from django import forms >>> from django.contrib.auth.models import User >>> >>>

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
> You should be looking in cleaned_data, see: > > http://docs.djangoproject.com/en/1.0/topics/forms/#processing-the-dat... > > For a ModelMultipleChoiceField, cleaned_data will be a list of model > instances. You shouldn't even have to think about the pk s. > > sdc yeah i'm still lost... this is

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Sam Chuparkoff
On Sun, 2009-05-17 at 18:43 -0700, Bobby Roberts wrote: > in my view i have this: > > > if request.method=='POST': > form=FrmIdMessage(request.POST) > if form.is_valid(): #process valid form here > assert False, request.POST.get('posted_to','') > [snip] You

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
On May 17, 4:23 pm, Bobby Roberts wrote: > > ...     users = forms.ModelMultipleChoiceField( > > ...         queryset=User.objects, > > ...         widget=forms.CheckboxSelectMultiple, > > ...         required=True) > > ...>>> User(username='sdc').save() > > >>>

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
On May 17, 4:23 pm, Bobby Roberts wrote: > > ...     users = forms.ModelMultipleChoiceField( > > ...         queryset=User.objects, > > ...         widget=forms.CheckboxSelectMultiple, > > ...         required=True) > > ...>>> User(username='sdc').save() > > >>>

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
On May 17, 4:23 pm, Bobby Roberts wrote: > > ...     users = forms.ModelMultipleChoiceField( > > ...         queryset=User.objects, > > ...         widget=forms.CheckboxSelectMultiple, > > ...         required=True) > > ...>>> User(username='sdc').save() > > >>>

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Sam Chuparkoff
.id]='%s %s' %(i.first_name,i.last_name) > return self.items() > > #used to post messages to oher users > class FrmIdMessage (forms.Form): > posted_to = forms.ChoiceField > (required=True,widget=forms.CheckboxSelectMultiple(attrs= > {'class':'optchecklist'},choices=myuser

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
> ...     users = forms.ModelMultipleChoiceField( > ...         queryset=User.objects, > ...         widget=forms.CheckboxSelectMultiple, > ...         required=True) > ...>>> User(username='sdc').save() > >>> User(username='bobby').save() dude you rock... i totally missed this. Does exactly

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
.CheckboxSelectMultiple(attrs= {'class':'optchecklist'},choices=myuserlist(userdata))) message = forms.CharField (max_length=300, required=True, widget=forms.Textarea(attrs={'class':'smallblob'})) ~ --~--~-~--~~~---~--~~ You received this message because you

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Lokesh
to post messages to oher users > class FrmIdMessage (forms.Form): >     posted_to = forms.ChoiceField > (required=True,widget=forms.CheckboxSelectMultiple(attrs= > {'class':'optchecklist'},choices=myuserlist(userdata))) >     message = forms.CharField (max_length=300, require

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
> Try this below code. I guess this will solve your purpose > >  # pull a recordset of the users >  userdata = auth_user.objects.all() > >  def user_filler(self): >      for i in userdata: >          self[i.id] = '%s, %s', (i.firstname, i.lastname) >      return self.items() > from django

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Lokesh
> >     incr = 0 > >     for i in p: > >        self[incr] = i.country > >        incr = incr+1 > >     return self.items() > > > country = forms.CharField(label="cnty", > > widget=forms.CheckboxSelectMultiple(choices=country_filler > &g

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
ntry >        incr = incr+1 >     return self.items() > > country = forms.CharField(label="cnty", > widget=forms.CheckboxSelectMultiple(choices=country_filler > (country_list))) > ok here's what i have based on that example: from django import forms # pull a reco

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Alex Gaynor
, > Lokesh > > > >incr = 0 > > >for i in p: > > > self[incr] = i.country > > > incr = incr+1 > > >return self.items() > > > > > country = forms.CharField(label="cnty", > > > widget=form

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Lokesh
> >    return self.items() > > > country = forms.CharField(label="cnty", > > widget=forms.CheckboxSelectMultiple(choices=country_filler > > (country_list))) > > > Hope the above lines will help you. > > > Regards, > > Lokesh > > >

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Alex Gaynor
ch from the records >incr = 0 >for i in p: > self[incr] = i.country > incr = incr+1 >return self.items() > > country = forms.CharField(label="cnty", > widget=forms.CheckboxSelectMultiple(choices=country_filler > (country_list))) > > H

Re: Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread lokeshmaremalla
return self.items() country = forms.CharField(label="cnty", widget=forms.CheckboxSelectMultiple(choices=country_filler (country_list))) Hope the above lines will help you. Regards, Lokesh On May 17, 7:10 pm, Bobby Roberts <tchend...@gmail.com> wrote: > Hi.  I'm needing to learn how

Seeking Example of MultipleChoiceField Example with dynamic Choices

2009-05-17 Thread Bobby Roberts
Hi. I'm needing to learn how to dynamically pull data out of the database and pass it as a CHOICES argument in my form. I want to pull a recordset of options, dump it into the choices and pass it to the form etc. Can someone out there lend me a hand? I'd like the options on the form

Re: Limiting Choices of a ForeignKey with 'self'.

2009-05-14 Thread Margie
related_name='t_release', null=True, blank=True) > >         a_release = models.ForeignKey(Release, > > verbose_name="A-Environment",   > > related_name='a_release', null=True, blank=True) > >         p_release = models.ForeignKey(Release, > > verbose_name="P-Environme

Re: Limiting Choices of a ForeignKey with 'self'.

2009-05-14 Thread Jamie
works in the admin interface, i can select Releases for each   > OTAP i have for each of the 4 environments. However i would like to   > limit the choices of the environments to just those releases that   > belong to that OTAP. I've tried to work with the 'limit_choices_to'   > from the

Re: limiting choices for foreign key choices in the admin view

2009-05-08 Thread Margie
yes, gotcha - that makes sense. Thanks. Margie On May 7, 10:59 pm, George Song <geo...@damacy.net> wrote: > On 5/7/2009 9:19 PM, Margie wrote: > > > > > Thanks much George, that was a big help.  I have some "proof of > > concept code below" that

Re: limiting choices for foreign key choices in the admin view

2009-05-07 Thread George Song
On 5/7/2009 9:19 PM, Margie wrote: > Thanks much George, that was a big help. I have some "proof of > concept code below" that simply limits choices to the first four > users, and I have verified that that works. > > class TaskAdmin(admin.ModelAdmin): > >

Re: limiting choices for foreign key choices in the admin view

2009-05-07 Thread Margie
Thanks much George, that was a big help. I have some "proof of concept code below" that simply limits choices to the first four users, and I have verified that that works. class TaskAdmin(admin.ModelAdmin): def formfield_for_dbfield(self, db_field, **kwargs): if db_

Re: limiting choices for foreign key choices in the admin view

2009-05-07 Thread George Song
s.Model): > owner = models.ForeignKey('auth.User') > resources = models.ManyToManyField('auth.User') > > The resources field identifies the set of possible owners for the > task. I would like to have the admin change_list view show the > resources as the choices for the owner field, ra

limiting choices for foreign key choices in the admin view

2009-05-07 Thread Margie
= models.ManyToManyField('auth.User') The resources field identifies the set of possible owners for the task. I would like to have the admin change_list view show the resources as the choices for the owner field, rather than showing all Users. Has anyone had success doing this? Can someone point me in the right

Choices validation on model fields

2009-04-30 Thread Jeremy Epstein
Hi, I have a model with a number of fields that use Django's 'choices' attribute, to limit the allowed values of those fields to a pre-defined list. I assumed that the Model system would validate my fields when I create or update them, to ensure that invalid choices weren't being assigned

Re: Limiting Choices of a ForeignKey with 'self'.

2009-04-28 Thread Jamie
I have the same problem and am hoping that a solution to one will work for both of us. In my case, I am working on an online newspaper site. My models for this particular app are Issue and Article. Articles are assigned to Issues so that they can all be published when the issue is published. That

Choices on CharField suppresses non-choice data in admin

2009-04-22 Thread Wyley
Hello all, I'm wondering if the following behavior is a feature, a bug, or a coding error on my part: when I define a model with a CharField that has choices, if I later save an instance of the model with a value for that field which is not one of the choices, the value does not display

Limiting Choices of a ForeignKey with 'self'.

2009-04-09 Thread Nicky Bulthuis
all works in the admin interface, i can select Releases for each OTAP i have for each of the 4 environments. However i would like to limit the choices of the environments to just those releases that belong to that OTAP. I've tried to work with the 'limit_choices_to' from the ForeignKey, but i've

Re: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Adam Stein
ntent_type = models.ForeignKey(ContentType, limit_choices_to= > {'id__in': CONTENT_TYPE_CHOICES}) > > > On Apr 1, 11:48 am, Lee <leetr...@gmail.com> wrote: > > You're close... > > > > change your method in CHOICES to get_for_model( _model_ ) > >

Re: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Lee
(ContentType, limit_choices_to= {'id__in': CONTENT_TYPE_CHOICES}) On Apr 1, 11:48 am, Lee <leetr...@gmail.com> wrote: > You're close... > > change your method in CHOICES to get_for_model( _model_ ) > > So it should be > CHOICES = ( >         (ContentType.objects.get_fo

Re: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Adam Stein
Thanks for the info. I also ran across 'limit_choices_to' which also works. On Wed, 2009-04-01 at 08:48 -0700, Lee wrote: > You're close... > > change your method in CHOICES to get_for_model( _model_ ) > > So it should be > CHOICES = ( > (ContentType.objects.g

Re: Can I limit the choices in a ContentType field in admin?

2009-04-01 Thread Lee
You're close... change your method in CHOICES to get_for_model( _model_ ) So it should be CHOICES = ( (ContentType.objects.get_for_model(My_Model), "Model 1"), (ContentType.objects.get_for_model(My_Other_Model), "Model 2"), ) Obviously, make sure y

Re: How do I define choices in ChoiceField

2009-03-27 Thread Joshua Partogi
Thanks for the hints guys. It works now. :-) On Mar 28, 12:49 am, Stephan John <em...@stephanjohn.de> wrote: > Am Freitag, 27. März 2009 14:43:08 schriebJoshuaPartogi: > > > bel = forms.ChoiceField(choices=({'one':'one','two':'two'}) ) > > it must be tuples: > > b

Re: How do I define choices in ChoiceField

2009-03-27 Thread Briel
Hi. Choices is a tuple/list of tuples/lists, so in your case it would look like this: (('one', 'one'), ('two', 'two')) You can't use dictionaries. ~Jakob On 27 Mar., 14:43, Joshua Partogi <joshua.j...@gmail.com> wrote: > Hi all, > > Let me just get straight to the point > I tr

Re: How do I define choices in ChoiceField

2009-03-27 Thread Stephan John
Am Freitag, 27. März 2009 14:43:08 schrieb Joshua Partogi: > bel = forms.ChoiceField(choices=({'one':'one','two':'two'}) ) it must be tuples: bel = forms.ChoiceField(choices=(('one', 'one'), ('two', 'two' ) ) --~--~-~--~~~---~--~~ You received this mess

How do I define choices in ChoiceField

2009-03-27 Thread Joshua Partogi
Hi all, Let me just get straight to the point I tried these: label = forms.ChoiceField(choices=({'one':'one','two':'two'}) ) And received these: Exception Type: TemplateSyntaxError Exception Value:Caught an exception while rendering: too many values to unpack What was wrong

Re: Limiting choices to a field in the user profile

2009-03-25 Thread Rajesh Dhawan
> In my models, I'm trying to limit the choices of a field based on the > data stored in a field in the user profile table. You will want to define these limits in your forms rather than in the models. > However, I have not been successful. I'm trying to learn Django, so > I'm still

Limiting choices to a field in the user profile

2009-03-25 Thread DeviantBoi
Hi! In my models, I'm trying to limit the choices of a field based on the data stored in a field in the user profile table. However, I have not been successful. I'm trying to learn Django, so I'm still a noob when it comes to it. Also, is the user profile table supposed to have an id field

Can I limit the choices in a ContentType field in admin?

2009-03-23 Thread Adam Stein
Trying to create a generic FK using ContentType. In admin, the menu lists all the models. Since I only ever need to select 1 of 2 different models, anyway to limit the choice? Setting the choices attribute as Django complains must be a "ContentType" instance ContentType.o

Re: how to show currently selected choices in ManyToMany fo

2009-02-24 Thread Margie
I think I'm going to try to come up with a more exact example of what I'm doing. I spent all last evening on this - could just not get the initial values set on my ModelMultipleChoiceForm. I guess I'll have to back up and start using a manage.py shell and pdb and step thrrough the django code

Re: how to show currently selected choices in ManyToMany fo

2009-02-24 Thread Daniel Roseman
On Feb 24, 5:09 am, Margie wrote: > Ok - I think I should actually be using initial - but still haven't > gotten that to actually work.  I'm trying something like this: > > In models.py > class Book(models.Model): >      title = models.CharField(max_length=100) >      

Re: how to show currently selected choices in ManyToMany fo

2009-02-23 Thread Margie
Ok - I think I should actually be using initial - but still haven't gotten that to actually work. I'm trying something like this: In models.py class Book(models.Model): title = models.CharField(max_length=100) authors = models.ManyToManyField(Author) pulisher =

how to show currently selected choices in ManyToMany fo

2009-02-23 Thread Margie
Let's say I have a model like this: class Book(models.Model): title = models.CharField(max_length=100) authors = models.ManyToManyField(Author) pulisher = models.ForeignKey(Publisher, blank=True, null=True) I want to generate a form that can be used to edit an existing Book object.

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Alex Gaynor
On Thu, Feb 12, 2009 at 3:49 PM, Michael Repucci wrote: > > Oh, bummer. Is there a *not so good* way to do it in 1.0.2? It'd be > nice to do it at all. > > Or is it perhaps not as scary as I think (as a newbie) to use the > latest development version? > > On Feb 12, 3:35 pm,

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Michael Repucci
Oh, bummer. Is there a *not so good* way to do it in 1.0.2? It'd be nice to do it at all. Or is it perhaps not as scary as I think (as a newbie) to use the latest development version? On Feb 12, 3:35 pm, Alex Gaynor wrote: > On Thu, Feb 12, 2009 at 3:33 PM, Michael

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Alex Gaynor
On Thu, Feb 12, 2009 at 3:33 PM, Michael Repucci wrote: > > It seems that the formfield_for_dbfield method doesn't have a hook for > the request. So unless I'm mistaken, I can't use it to filter the > Contact instances by the currently logged in user (request.user). Any >

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Michael Repucci
It seems that the formfield_for_dbfield method doesn't have a hook for the request. So unless I'm mistaken, I can't use it to filter the Contact instances by the currently logged in user (request.user). Any other thoughts? On Feb 12, 3:12 pm, Michael Repucci wrote: > Oh. It

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Alex Gaynor
On Thu, Feb 12, 2009 at 3:12 PM, Michael Repucci wrote: > > Oh. It doesn't mention that in the documentation. I am using 1.0.2- > final. I'll check out formfield_for_dbfield. Thanks for the pointer! > > On Feb 12, 3:09 pm, Alex Gaynor wrote: > > On

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Michael Repucci
Oh. It doesn't mention that in the documentation. I am using 1.0.2- final. I'll check out formfield_for_dbfield. Thanks for the pointer! On Feb 12, 3:09 pm, Alex Gaynor wrote: > On Thu, Feb 12, 2009 at 3:07 PM, Michael Repucci wrote: > > > > > > > I'm

Re: need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Alex Gaynor
On Thu, Feb 12, 2009 at 3:07 PM, Michael Repucci wrote: > > I'm new to Django, and already loving it. But I'm stumbling a bit with > how to accomplish the following task. Perhaps this isn't the best > approach, but most of the site is working as planned, and it was super >

need help limiting choices on admin form for ForeignKey field

2009-02-12 Thread Michael Repucci
I'm new to Django, and already loving it. But I'm stumbling a bit with how to accomplish the following task. Perhaps this isn't the best approach, but most of the site is working as planned, and it was super easy to get up and running. I have a Contact model and a Person model, the latter of

Re: Sorting by the human readable options in field provided with choices

2009-01-26 Thread Malcolm Tredinnick
On Mon, 2009-01-26 at 14:20 -0800, Jeromie wrote: > I have a model with a status field that includes a choices argument to > provide human readable options. Because the options were changing > during development, the values stored in the database are rather > generic - S01, S02, etc.

Sorting by the human readable options in field provided with choices

2009-01-26 Thread Jeromie
I have a model with a status field that includes a choices argument to provide human readable options. Because the options were changing during development, the values stored in the database are rather generic - S01, S02, etc. There is one view in my application that provides a list of all

Re: dynamic / updating foreign key choices

2009-01-13 Thread raj
eignkeyfield toselectthe > ResourceType, and a ManyToManyField to link to the Resource > model. > > I would like the user to be able to enter the dates to and from, andselectthe > resource type. Then from these choices this would only show > those resources available that

Re: Cannot resolve keyword 'user' into field. Choices are: id, job, name

2009-01-12 Thread John Baker
interestingly changing candidate = request.candidate (retrieved from middleware) to candidate = Candidate.objects.filter(user=request.user) and then doing .delete() works. Very strange behaviour. I don't understand the ORM well enough to know why it would get confused. On Jan 12, 2:43 pm,

dynamic / updating foreign key choices

2009-01-12 Thread GuyBowden
and a ManyToManyField to link to the Resource model. I would like the user to be able to enter the dates to and from, and select the resource type. Then from these choices this would only show those resources available that belong to the specific resource type. I have defined an "is_available" met

Re: Cannot resolve keyword 'user' into field. Choices are: id, job, name

2009-01-12 Thread John Baker
The candidate object is attached to the request object by middleware. class CandidateCheckMiddleware(object): def process_view(self, request, view, args, kwargs): candidate = request.user.is_authenticated() and \ Candidate.objects.filter(user=request.user) if

Re: Cannot resolve keyword 'user' into field. Choices are: id, job, name

2009-01-12 Thread Szymon
On 12 Sty, 15:40, John Baker wrote: > # later in code trying to delete > candidate.delete() > > Any clues? (Django 1.0.2 final) You need to provide how you fetch objects, I mean code before cadidate.delete(). --~--~-~--~~~---~--~~ You

Cannot resolve keyword 'user' into field. Choices are: id, job, name

2009-01-12 Thread John Baker
I cannot delete an object that has a foreign key to a user. The error given is: Cannot resolve keyword 'user' into field. Choices are: id, job, name # the model class Candidate(models.Model): user = models.ForeignKey(User) ... # later in code trying to delete candidate.delete

filter field choices after selecting another field with javascript in django admin

2008-11-25 Thread Alessandro Ronchi
It should be very useful to filter a select field in django admin when selecting another field. Somethin like: fieldA = foreignKey(Country) fieldB = foreignKey(State) when user selects fieldA it should be shown only its states and not all countries' states. Is it possible? Someone wrote some

Re: Custom Select widget choices - how to reuse choices?

2008-11-22 Thread Donn
On Saturday, 22 November 2008 03:52:27 Jeff FW wrote: > choices = Movie._meta.get_field('disk_type').choices Ah, the 'Movie' in there was the missing voodoo. I was stuck on using an instance; and yes, I prefer Movie dot choices 'global' idea. Thanks for the various replies. I have more-or-l

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Jeff FW
You could define the CHOICES as a member of your model class, like so: class Movie( Relic ): CHOICES=((u'1','one'), (u'2',u'two')) disk_type = models.CharField( 'Type', max_length=8, choices=CHOICES) Then, in your form: class MovieForm( BasicRelicForm ): disk_type = forms.CharField

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Donn
On Friday, 21 November 2008 13:46:35 Daniel Roseman wrote: > There is an alternative, though: instead of overriding the fields > declaratively, you can define a formfield_callback function. This seems interesting. I have searched the docs online for 'formfield_callback' and get no useful

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Daniel Roseman
On Nov 21, 9:09 am, Donn <[EMAIL PROTECTED]> wrote: > On Friday, 21 November 2008 08:06:32 urukay wrote: > > > easy way how to solve it is to put definition of your choices out of model > > definition: > > Yeah, that's what I call a 'global', but is there no

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread urukay
u can use ModelForm and you don't have to write choices. Don't know any other way. But I don't suppose there is other way, these two "ways" can solve everything, I think. Or maybe someone else would help R. Donn Ingle wrote: > > > On Friday, 21 November 2008 08:06:32 ur

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Donn
On Friday, 21 November 2008 08:06:32 urukay wrote: > easy way how to solve it is to put definition of your choices out of model > definition: Yeah, that's what I call a 'global', but is there no way to get the choices from the field in the model clas

Re: Custom Select widget choices - how to reuse choices?

2008-11-20 Thread urukay
easy way how to solve it is to put definition of your choices out of model definition: CHOICES=((u'1','one'), (u'2',u'two')) class Movie( Relic ): disk_type = models.CharField( 'Type', max_length=8, choices=CHOICES) and then you can import CHOICES whereever you want and reuse it from

Re: Filtered choices list for a m2m field from an m2m field within another model.

2008-11-20 Thread Silvano
myself. In the docs it says "limit_choices_to has no effect when used on a ManyToManyField with an intermediate table". So my choices list would have no effect if it worked. Maybe you could give me some general advice on how to approach what I had mind. Thanks - Silvan On Nov 2

Custom Select widget choices - how to reuse choices?

2008-11-20 Thread Donn
Hello, In my model, I define the choices for a charfield. I make a ModelForm of that model but I want my own widget for that field. How can I pass-through the choices I defined in my model? Some code: class Movie( Relic ): disk_type = models.CharField( 'Type', max_length=8, choices=((u'1

Re: Filtered choices list for a m2m field from an m2m field within another model.

2008-11-19 Thread Malcolm Tredinnick
gt; class Project(models.Model): > title = models.CharField(max_length=100) > client = models.ManyToManyField(Contact, related_name='client', > blank=True) > collaborators = models.ManyToManyField(Contact, > related_name='collaborators', blank

Re: dynamic choices iterator in model field

2008-11-19 Thread Malcolm Tredinnick
On Wed, 2008-11-19 at 09:42 -0800, Delta20 wrote: > A model field may have a 'choices' option to which you assign an > iterable object -- typically a list, but this can also be an iterable > function. Is there a way to assign a class method/function rather than > a module function?

Filtered choices list for a m2m field from an m2m field within another model.

2008-11-19 Thread Silvano
lank=True) collaborators = models.ManyToManyField(Contact, related_name='collaborators', blank=True) What I tried so far is to use a filter for constructing a choices list within the “Project” model. related_contacts = Contact.objects.filter (projects_involved__title__starts_with=title) This g

dynamic choices iterator in model field

2008-11-19 Thread Delta20
A model field may have a 'choices' option to which you assign an iterable object -- typically a list, but this can also be an iterable function. Is there a way to assign a class method/function rather than a module function? Here's what I'm trying to do: I have a model, "Ticket"

Re: how to implement multiple choices in model

2008-11-18 Thread Karen Tracey
On Mon, Nov 17, 2008 at 9:56 PM, Canhua <[EMAIL PROTECTED]> wrote: > > 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

Re: how to implement multiple choices in model

2008-11-18 Thread Canhua
On Nov 18, 3:52 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > Usually you'd do this as a ManyToMany field. However I know you > sometimes do want to do it in a custom model field - I've just posted > my implementation at > djangosnippets:http://www.djangosnippets.org/snippets/1200/ > I've

Re: how to implement multiple choices in model

2008-11-18 Thread Canhua
On Nov 18, 3:52 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > Usually you'd do this as a ManyToMany field. However I know you > sometimes do want to do it in a custom model field - I've just posted > my implementation at > djangosnippets:http://www.djangosnippets.org/snippets/1200/ > I've

Re: how to implement multiple choices in model

2008-11-17 Thread Daniel Roseman
On Nov 18, 2:56 am, Canhua <[EMAIL PROTECTED]> wrote: > 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

<    1   2   3   4   5   6   7   8   9   >