Re: Allow a limit_choices_to callable to accept the current model instances object

2018-09-25 Thread Tim Graham
auto_now_add=True) > > class Profile(models.Model): > user = models.OneToOneField(settings.AUTH_USER_MODEL, > on_delete=models.CASCADE, > editable=False) > subscription = models.ForeignKey(Subscription, limit_choices_to={'user_id': > settings.AUTH_USER_MODEL}, on_delete=models.

Allow a limit_choices_to callable to accept the current model instances object

2018-09-25 Thread Ochui Princewill
) expires = models.DateField() created_at = models.DateTimeField(auto_now_add=True) class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, editable=False) subscription = models.ForeignKey(Subscription, limit_choices_to={'user_id

Re: New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-10 Thread germano carella
a new book. It's very simple, but I can't find a way to make it working. I tried somethings, such as chapters= models.ManyToManyField('Chapters',limit_choices_to=Q('book__title'=title)) But this not works. I know Chapters has book_set, that is the set of references f

Re: New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread germano carella
t find a way to make it working. I tried somethings, such as chapters= models.ManyToManyField('Chapters',limit_choices_to=Q('book__title'=title)) But this not works. I know Chapters has book_set, that is the set of references for a chapter. There is a way to make it wo

Re: New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread Julio Biason
see only chapter of this book. List must be > empty if I'm adding a new book. > It's very simple, but I can't find a way to make it working. > > I tried somethings, such as > chapters= models.ManyToManyField('Chapters',limit_choices_to=Q(' > book__title'=title)) > But

New member: Germano Carella. I need help with django, limit_choices_to and admin interface

2018-08-09 Thread Germano Carella
chapters of book I added previously. When I add a new book I want see only chapter of this book. List must be empty if I'm adding a new book. It's very simple, but I can't find a way to make it working. I tried somethings, such as chapters= models.ManyToManyField('Chapters',limit_choices_to=Q

Re: 2.1b1: Getting "unexpected keyword argument 'limit_choices_to'"

2018-07-05 Thread Axel Rau
Thanks Markus for the hint. f3fa86a fixed the problem. > Am 04.07.2018 um 17:11 schrieb Markus Holtermann >: > > Thanks for the report Axel. This seems to be the same issue as the one > reported in https://code.djangoproject.com/ticket/29449 >

Re: 2.1b1: Getting "unexpected keyword argument 'limit_choices_to'"

2018-07-04 Thread Markus Holtermann
kwargs, > File > "/usr/local/py_env/erdb_d2.1+p3.6/lib/python3.6/site-packages/django/db/models/fields/related.py", > > line 418, in formfield > return super().formfield(**defaults) > File > "/usr/local/py_env/erdb_d2.1+p3.6/lib/python3.6/site

Re: 2.1b1: Getting "unexpected keyword argument 'limit_choices_to'"

2018-07-04 Thread Jason
n formfield > **kwargs, > File > "/usr/local/py_env/erdb_d2.1+p3.6/lib/python3.6/site-packages/django/db/models/fields/related.py", > > line 418, in formfield > return super().formfield(**defaults) > File > "/usr/local/py_env/erdb_d2.1+p

2.1b1: Getting "unexpected keyword argument 'limit_choices_to'"

2018-07-04 Thread Axel Rau
local/py_env/erdb_d2.1+p3.6/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 890, in formfield return form_class(**defaults) File "/usr/local/py_env/erdb_d2.1+p3.6/lib/python3.6/site-packages/django/forms/fields.py", line 213, in __init__ super().__i

Re: limit_choices_to=function() not work in python-3.6+django-1.11.2

2017-06-28 Thread Tim Graham
The new ticket is https://code.djangoproject.com/ticket/28345. On Wednesday, June 28, 2017 at 5:03:54 PM UTC-4, Tim Graham wrote: > > A new ticket is appropriate since the changes for the original ticket are > already released. Please include more explicit steps about how to reproduce > the

Re: limit_choices_to=function() not work in python-3.6+django-1.11.2

2017-06-28 Thread Tim Graham
A new ticket is appropriate since the changes for the original ticket are already released. Please include more explicit steps about how to reproduce the issue -- it's difficult for me to tell exactly what the issue is from the details you provided so far. On Wednesday, June 28, 2017 at

Re: limit_choices_to=function() not work in python-3.6+django-1.11.2

2017-06-28 Thread Drunkard Zhang
On Wednesday, June 28, 2017 at 10:11:35 PM UTC+8, Drunkard Zhang wrote: > > > > On Wednesday, June 28, 2017 at 7:56:36 PM UTC+8, Tim Graham wrote: >> >> To get some insight, I'd try bisecting to find the Django commit where >> the behavior changed: >> >>

Re: limit_choices_to=function() not work in python-3.6+django-1.11.2

2017-06-28 Thread Drunkard Zhang
t;> >> Hi, fellows: >> >> I was running python-3.4+django-1.9.13 previous, and upgrading to >> python-3.6+django-1.11.2, while testing, I found that my limit_choices_to >> function not working now, here's detail. >> >> I'm using a middleware to get current us

Re: limit_choices_to=function() not work in python-3.6+django-1.11.2

2017-06-28 Thread Tim Graham
> > I was running python-3.4+django-1.9.13 previous, and upgrading to > python-3.6+django-1.11.2, while testing, I found that my limit_choices_to > function not working now, here's detail. > > I'm using a middleware to get current user who is accessing my site, and > use it i

limit_choices_to=function() not work in python-3.6+django-1.11.2

2017-06-28 Thread Drunkard Zhang
Hi, fellows: I was running python-3.4+django-1.9.13 previous, and upgrading to python-3.6+django-1.11.2, while testing, I found that my limit_choices_to function not working now, here's detail. I'm using a middleware to get current user who is accessing my site, and use it in limit_choices_to

Problem with limit_choices_to and filtering foreign key

2014-08-01 Thread Hilde Rafaelsen
"RfC State") effectOnUsers = models.NullBooleanField("Effect", blank=True, null=True) class RfcStatus(models.Model): rfcd = models.AutoField (primary_key=True) rfcStatusDateCreated = models.DateField("Created date", default=datetime.now()) rfc_details = models.Fo

Re: Django limit_choices_to - ForeignKey

2014-07-31 Thread cmawebsite
If you are using the admin: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_choice_field Otherwise, you'll need to dynamically create that field or the entire form. -- You received this message because you are subscribed to the Google

Django limit_choices_to - ForeignKey

2014-07-23 Thread Ganea Ionut
Hello there, Recently i've been tasked with using the 'limit_choices_to' attribute of a ForeignKey field, in order to limit choices. My models are like this (params -> max_length, choices, etc): class DeviceFeatures(models.Model): # declare choices here: feature_choices # featu

Foreign key field with limit_choices_to

2014-06-04 Thread dmbarbour87
= models.CharField(max_length=255) product = models.ForeignKey(Product, limit_choices_to=Q(group_sku__in=product_sku)) ... I'm importing my data to Django from an XML file via a python script. group_sku comes in the format "GROUP123" product_sku comes in the format "

Re: ManyToManyField causes invalid form when limit_choices_to argument set

2014-04-30 Thread rgreene
Solved! It turned out the problem only occurred trying to uncheck the last checkbox. I needed to set blank=True on the ManyToManyField. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails

ManyToManyField causes invalid form when limit_choices_to argument set

2014-04-30 Thread rgreene
)* *class Continent(models.Model):* *continent_id = models.AutoField(primary_key=True)* *continent_name = models.CharField(max_length=200)* *country = models.ManyToManyField(Country, db_table='continent_country', limit_choices_to=Q(country_id__exact=1))* *class Meta:* *

Re: .annotate() in limit_choices_to?

2013-05-28 Thread galgal
I wrote some code, but it returns doubled entries if there's no annotate: price_variants = models.ManyToManyField( ProductPriceVariant, verbose_name=_(u'price variants'), limit_choices_to=Q(translation__language__iexact=get_language()[:2]) &

.annotate() in limit_choices_to?

2013-05-28 Thread galgal
Is it possible to put, somehow, *.annotate()* method into M2M * limit_choices_to*? I need to limit my choices to that query: * cls.objects.annotate(subproducts_num=models.Count('subproducts')).filter(subproducts_num__gt=0) * Any ideas? -- You received this message because you are subscribed

Test limit_choices_to

2013-05-28 Thread galgal
Is there any way to test if my *limit_choices_to* argument is working as I expect? How can I test that in unit test? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails fro

Re: ManyToManyField limit_choices_to that instance via Django admin.

2011-06-07 Thread Micky Hulse
Hi Ryan! Thanks so much for the reply, I really appreciate the help. :) On Tue, Jun 7, 2011 at 12:17 PM, Ryan <ryan.osb...@live.co.uk> wrote: > This is possible, but I'm not sure if you could do it via limit_choices_to. > The admin docs shows how to accomplish this here: Oooh, in

Re: ManyToManyField limit_choices_to that instance via Django admin.

2011-06-07 Thread Ryan
This is possible, but I'm not sure if you could do it via limit_choices_to. The admin docs shows how to accomplish this here: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany Ryan -- You received this message because you

ManyToManyField limit_choices_to that instance via Django admin.

2011-06-06 Thread mhulse
Hello, Here's some example code: [code] class Creative(...): file2 = models.ManyToManyField('Asset', ...) class Asset(...): file = models.FileField(...) [/code] Can I use limit_choices_to to limit "Asset" to only the files that were uploaded by the curren

Re: limit_choices_to (or some other way) to filter ForeignKey choices based on current model field

2011-04-19 Thread Derek
x_length=255) >     mymodel = models.ForeignKey(MyModel) > > class MyModelItem(models.Model): >     mymodel = models.ForeignKey(MyModel) >     other = models.ForeignKey(OtherModel, null=True, blank=True) > === > > how can i use limit_choices_to (or some other way) to filte

limit_choices_to (or some other way) to filter ForeignKey choices based on current model field

2011-04-16 Thread Aljoša Mohorović
(MyModel) other = models.ForeignKey(OtherModel, null=True, blank=True) === how can i use limit_choices_to (or some other way) to filter ForeignKey choices based on current model field? basically, how can i do: other = models.ForeignKey(OtherModel, null=True, blank=True, limit_choices_to

ManyToMany using through and limit_choices_to

2010-11-22 Thread Ferran
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 I've seen on the docs that is not possible to use limit_choices_to with a ManyToMany relationship using intermediate tables with through parameter. I need to have an "ordered" ManyToMany relationship, and i'm using an intermediate table

Re: How to dynamically set limit_choices_to for ManyToManyField using values from an instance?

2010-06-04 Thread Massimiliano della Rovere
the unsed ones (in the context of >> o). >> >> The problem is that I am not allowd to write self.choices_for_n() >> >> Does anybody know any solution for this? >> >> class A(models.Model): >>         o = models.ForeignKey(O) >>         p = models

Re: How to dynamically set limit_choices_to for ManyToManyField using values from an instance?

2010-06-04 Thread Scott Gould
in use by a and the unsed ones (in the context of > o). > > The problem is that I am not allowd to write self.choices_for_n() > > Does anybody know any solution for this? > > class A(models.Model): >         o = models.ForeignKey(O) >         p = models.ManyToManyField(P

How to dynamically set limit_choices_to for ManyToManyField using values from an instance?

2010-06-04 Thread Massimiliano della Rovere
the unsed ones (in the context of o). The problem is that I am not allowd to write self.choices_for_n() Does anybody know any solution for this? class A(models.Model): o = models.ForeignKey(O) p = models.ManyToManyField(P) n = models.ManyToManyField(N, limit_

Re: Need limit_choices_to help

2010-03-20 Thread Walt
Is this the type of solution you have in mind? http://tinyurl.com/yaqjfx4 Walt -~ -- 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. To unsubscribe from this group, send email

Re: Need limit_choices_to help

2010-03-19 Thread bax...@gretschpages.com
Looking at this more, I think I may have more of a logic problem I think Play can't have any idea of Game roster, because until it's been saved it has no idea what game it's related to. So maybe what I need is a way to dynamically fill the player field on Play, after game has been selected.

Need limit_choices_to help

2010-03-19 Thread bax...@gretschpages.com
on the roster for that game. In my head, it should be something like playmaker = models.ForeignKey(Player, limit_choices_to= {'id': 'game__roster'}, Or am I looking at it all wrong? Should I build a choice list from roster on the fly and use that? OR can I just foreignKey straight to Game__roster

Re: limit_choices_to a value on a field in the same model

2010-03-14 Thread Brandon Taylor
Walt, you're a lifesaver! Many thanks for the great example. I only made a couple of minor tweeks: class AgencyForm(forms.ModelForm): class Meta: model = Agency def __init__(self, *args, **kwargs): super(AgencyForm, self).__init__(*args, **kwargs) if

Re: limit_choices_to a value on a field in the same model

2010-03-14 Thread Walt
Here is an idea of what your forms.py should contain: class AgencyForm(ModelForm): class Meta: model = Agency def __init__(self, *args, **kwargs): super(AgencyForm, self).__init__(*args, **kwargs) if self.instance.id: if self.instance.state_id:

limit_choices_to a value on a field in the same model

2010-03-13 Thread Brandon Taylor
Evening Everyone, I have a model "Agency" with "state" as a foreign key and "counties" as a many-to-many. County has a foreign key to "state" I would like to limit the County choices in Django admin to the state of the Agency being edited, but, I can't seem to find the right place to get an

Re: Can I use request.user, in the limit_choices_to filter in Model class?

2010-02-25 Thread zinckiwi
> I need to filter a field by a UserProfile function, i.e. how can I do > something like this? > > class Paquet(models.Model): >     ... >     profiles = models.ManyToManyField(UserProfile, limit_choices_to = > {'country': request.user.userprofile.country}) I'd put th

Can I use request.user, in the limit_choices_to filter in Model class?

2010-02-24 Thread Luis Gonzalez
I need to filter a field by a UserProfile function, i.e. how can I do something like this? class Paquet(models.Model): ... profiles = models.ManyToManyField(UserProfile, limit_choices_to = {'country': request.user.userprofile.country}) Thanks in advance

Re: error with limit_choices_to with complex queries (Q object) and raw_id_fields

2009-10-13 Thread Russell Keith-Magee
'idGroup',verbose_name = 'Groupe',limit_choices_to = Q(state='valid') > | Q(state='modify')) >   idUser = models.ForeignKey(User,db_column = 'idUser',verbose_name = > 'Utilisateur',limit_choices_to = Q(state='valid') | Q(state='modify')) > > and in admin.py : > >

error with limit_choices_to with complex queries (Q object) and raw_id_fields

2009-10-13 Thread fsaintma
hello I have a model.py like this : class secondaryGroup(models.Model): id = models.AutoField(primary_key = True) idGroup = models.ForeignKey(Group,db_column = 'idGroup',verbose_name = 'Groupe',limit_choices_to = Q(state='valid') | Q(state='modify')) idUser = models.ForeignKey(User

Re: limit_choices_to & get_sql()

2009-09-23 Thread Nicolas Steinmetz
; before the merge of queryset-refactor before version 1.0 was released. > > Anyway, the syntax is simple: >     limit_choices_to = {'dnstype': 2} That's it, thanks. Indeed, I misunderstood the doc here : http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignke

Re: limit_choices_to & get_sql()

2009-09-22 Thread Daniel Roseman
dels.CharField(blank=True, max_length=100) >     dnstype = models.CharField(max_length=100, > choices=TYPEDNS_CHOICES) > > class Url(models.Model): >     """ >     Url description >     """ >     name = models.CharField(blank=True, max_length=10

limit_choices_to & get_sql()

2009-09-22 Thread Nicolas Steinmetz
t;" Url description """ name = models.CharField(blank=True, max_length=100) [...] cnamevalue = models.ForeignKey(Dns, limit_choices_to = {'dns': 'get_sql(Dns.dnstype="2")'}, blank=True) Could someone explain me what is the right syntax ? I could u

Re: limit_choices_to

2009-08-01 Thread Daniele Procida
On Sat, Aug 1, 2009, Ramiro Morales wrote: >If you need this for the admin app and are using Django 1.1 read about >the formfield_for_foreignkey ModelAdmin method: > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/

Re: limit_choices_to

2009-08-01 Thread Ramiro Morales
On Sat, Aug 1, 2009 at 12:05 PM, Daniele Procida wrote: > > I am trying to set up a model. > > A Person has a ManyToMany relationship with Entities. One of those > relationships is special - we can capture that with a ForeignKey > relationship to Entity. > > But, I want

limit_choices_to

2009-08-01 Thread Daniele Procida
a relationship with, by using a: limit_choices_to = {field: value}, So, I have tried various things that look like this: class Person(models.Model): entities = models.ManyToManyField( Entity, related_name = 'people', through ='Membership', ) home_entity

Re: ManyToMany field and limit_choices_to

2009-05-16 Thread adrian
pilot error, no need to reply On May 16, 10:41 am, adrian <adrian...@gmail.com> wrote: > I am creating a view to edit a model that has a ManyToMany field. > The field is defined as: > > performer = models.ManyToManyField(Entity, limit_choices_to= > {'role__exact':'PER'})

ManyToMany field and limit_choices_to

2009-05-16 Thread adrian
I am creating a view to edit a model that has a ManyToMany field. The field is defined as: performer = models.ManyToManyField(Entity, limit_choices_to= {'role__exact':'PER'}) Entity is a table of persons or organizations. Some of them are performers and some are not (distinguished by "

Re: limit_choices_to using a dynamic model attribute

2009-03-30 Thread Jamie
Ah, after playing with the code some more I resolved my own problem. Instead of relying on the 'is_active' dynamic model attribute for use with limit_choices_to, I was able to get the following to accomplish the same task: limit_choices_to={ 'end_date__gte': datetime.date.today, 'start_date__lte

limit_choices_to using a dynamic model attribute

2009-03-30 Thread Jamie
Is it possible to use limit_choices_to with a dynamic model attribute? Some background: I am using a StaffMember model for content creators who do not have user accounts. Each staff member has a start and end date and the model has a dynamic attribute called 'is_active' that compares the start

Re: How to properly use limit_choices_to on self-joins

2009-03-20 Thread Laran Evans
    clients              = models.ManyToManyField > ('self',blank=True,null=True,limit_choices_to={'id__ne':'id'}) > >         def __unicode__(self): >                 return u'%s' % self.name --~--~-~--~~~---~--~~ You received this message because you are s

How to properly use limit_choices_to on self-joins

2009-03-19 Thread Laran Evans
) clients = models.ManyToManyField ('self',blank=True,null=True,limit_choices_to={'id__ne':'id'}) def __unicode__(self): return u'%s' % self.name --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: referencing the current instance inside limit_choices_to

2008-12-10 Thread bruno desthuilliers
On 10 déc, 19:25, fiedzia <[EMAIL PROTECTED]> wrote: > On Dec 10, 1:56 am, GuyBowden <[EMAIL PROTECTED]> wrote: > > > I'd like to set the limit_choices_to value of a ForeignKey field based > > on another selection in the current instance. > (snip) > > other

Re: referencing the current instance inside limit_choices_to

2008-12-10 Thread fiedzia
On Dec 10, 1:56 am, GuyBowden <[EMAIL PROTECTED]> wrote: > I'd like to set the limit_choices_to value of a ForeignKey field based > on another selection in the current instance. Perhaps someone will come with better idea, but for now to achieve this result i am modifying quer

Re: referencing the current instance inside limit_choices_to

2008-12-10 Thread GuyBowden
Thankyou - saves me searching down this dead end... Cheers, Guy On Dec 10, 7:54 am, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > There is no way to have per-instance limit_choices_to. > > On Wed, Dec 10, 2008 at 03:56, GuyBowden <[EMAIL PROTECTED]> wrote: &g

Re: referencing the current instance inside limit_choices_to

2008-12-09 Thread Alex Koshelev
There is no way to have per-instance limit_choices_to. On Wed, Dec 10, 2008 at 03:56, GuyBowden <[EMAIL PROTECTED]> wrote: > > Hi, > > I've looked about but can't find the answer to this. > > I'd like to set the limit_choices_to value of a ForeignKey field base

referencing the current instance inside limit_choices_to

2008-12-09 Thread GuyBowden
Hi, I've looked about but can't find the answer to this. I'd like to set the limit_choices_to value of a ForeignKey field based on another selection in the current instance. i.e. - filter the choices based on another field of the same instance. something like this: my_fk.limit_choices_to

Re: Access the current instance from limit_choices_to?

2008-10-27 Thread Alex Rades
Also discussed here: http://groups.google.com/group/django-users/browse_thread/thread/51228899c5a9a6c/d49271983401e29e "If my original post was not entirely clear, I'm interested in any method available to limit_choices_to that lets you dynamically create the list of available op

Access the current instance from limit_choices_to?

2008-10-27 Thread Alex Rades
Hi, is there currently a way to have something like: class Mother(models.Model): firstborn = models.ForeignKey('Child', limit_choices_to={'mother':lambda me: me}) class Child(models.Model): mother = models.ForeignKey('Mother', related_name='children') (taken from http

dynamic values in limit_choices_to

2008-10-16 Thread yves_s
Hi I have this 2 models [CODE] class FontFamily(models.Model): name = models.CharField(max_length="50") default_fontfile = models.ForeignKey('FontFile', limit_choices_to = { 'id__in' : (1,2) }, # something like 'self.fontfile_set.al

Newbie help with limit_choices_to on ManyToMany

2008-10-06 Thread Lars Stavholm
n I've used up all hosts, the "Available hosts" form table should be empty. What's the best way to solve this? By using limit_choices_to somehow I guess. Any ideas appreciated /Lars --~--~-~--~~~---~--~~ You received this message because you are subscribed t

using limit_choices_to in foreignKey

2008-06-26 Thread mariu
hello, have the following problem with limit_choices_to: class Actividad(models.Model): nombre=CharField(max_length=50,core=True) Tipo_Anexo=ForeignKey('Tipo_Anexo',edit_inline=models.TABULAR) class Anexo_Contrato(models.Model): nombre=CharField(max_length=50

Re: help - limit_choices_to

2008-06-22 Thread M.Ganesh
Karen Tracey wrote: > On Sat, Jun 21, 2008 at 9:23 PM, M.Ganesh <[EMAIL PROTECTED] > > wrote: > > > Hi All, > > This question might have been answered so may times, but I am > unable to > glean the information I am looking for from the 260 odd entries

Re: help - limit_choices_to

2008-06-21 Thread Karen Tracey
On Sat, Jun 21, 2008 at 9:23 PM, M.Ganesh <[EMAIL PROTECTED]> wrote: > > Hi All, > > This question might have been answered so may times, but I am unable to > glean the information I am looking for from the 260 odd entries that > turn up while searching the mailing-list archives. So here I ask

help - limit_choices_to

2008-06-21 Thread M.Ganesh
Hi All, This question might have been answered so may times, but I am unable to glean the information I am looking for from the 260 odd entries that turn up while searching the mailing-list archives. So here I ask again #my models class entity(models.Model): name = models.Charfield()

help with limit_choices_to

2008-05-08 Thread Matias Surdi
Hi. I've the following model: class ExamAttributeCalification(models.Model): exam_result = models.ForeignKey(ExamResult, edit_inline=models.TABULAR, num_in_admin=1) exam_attribute = models.ForeignKey(ExamAttribute,limit_choices_to={"exam__id":1}) ca

Re: limit_choices_to in ModelForm

2008-01-19 Thread James Bennett
On Jan 19, 2008 3:51 AM, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > I have a limit_choices_to in my model - but this does work on my > ModelForm. How do I do this? Either set up the ModelChoiceField manually and specify the QuerySet, or hang on while I get around to adding tests

limit_choices_to in ModelForm

2008-01-19 Thread Kenneth Gonsalves
hi, I have a limit_choices_to in my model - but this does work on my ModelForm. How do I do this? -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ Foss Conference for the common man: http://registration.fossconf.in/web

newadmin: where is 'limit_choices_to'

2007-12-17 Thread René Schneider
Hello I am a newbe on this list. With the oldforms-admin i made a model with some fields with 'limit_choices_to' options. Then i tried it with the newadmin. There is no error message but also no effect. The list is not 'limited' but 'full'. Is this option gone in newadmin or have i to program

Re: complex query in limit_choices_to

2007-11-24 Thread leotr
On database level that should be done by UNIQUE constraints. And your problem should be made on form level. read about ChoiceField in newforms documentation --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

complex query in limit_choices_to

2007-11-23 Thread Kenneth Gonsalves
. This is the query I generate to get this list: Child.objects.extra( where=["""id not in(select child_id from web_sponsorship\ where web_sponsorship.iscurrent=True)"""] ).filter(iscurrent=True) how do i get this into the limit_choices_to dic

self referencing limit_choices_to

2007-11-05 Thread Brot
Hello, I have a little problem with the "limit_choices_to" functionality. I found two group discussions concerning the same problem, but the authors got no answers. http://groups.google.com/group/django-users/browse_thread/thread/fab619f35e322486/e9f34786dbba2666?lnk=gst=limit_

Re: limit_choices_to has no effect on list_filter?

2007-09-02 Thread patrickk
I already found a patch from 25.2.2007. Don´t know why it´s not in the trunk yet, but it seems to work. Patrick On 2 Sep., 21:27, patrickk <[EMAIL PROTECTED]> wrote: > I thought this has been working, but I´m not sure: > > content_type = models.ForeignKey(ContentType, l

limit_choices_to has no effect on list_filter?

2007-09-02 Thread patrickk
I thought this has been working, but I´m not sure: content_type = models.ForeignKey(ContentType, limit_choices_to = {'pk__in': [10, 24, 25, 26, 51]}) ... list_filter = ('createdate', 'updatedate', 'category', 'content_type',) in the filter, alle the content_types show up, although I´ve been

Re: Using limit_choices_to on a ManyToMany Field

2007-08-02 Thread Russell Keith-Magee
On 8/3/07, Greg <[EMAIL PROTECTED]> wrote: > > Come onI know that somebody can figure this out Greg - seriously, it's been 6 hours since your original message. Give people a chance to _read_ your message before you complain about the fact that nobody has answered. Yours, Russ Magee %-)

Re: Using limit_choices_to on a ManyToMany Field

2007-08-02 Thread Greg
Come onI know that somebody can figure this out sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice__id': self.collection.id}) What do I need to get the collection id? Will 'self.collection.id' work? I forgot to add my collection class. Here it is: class Collection

Using limit_choices_to on a ManyToMany Field

2007-08-02 Thread Greg
I've looked everywhere for information on how to use the 'limit_choices_to' attribute...but can't seem to find the answer. I have the following models: class Choice(models.Model): choice = models.ForeignKey(Collection, edit_inline=models.TABULAR, num_in_admin=5) size = models.ForeignKey

form_for_model and limit_choices_to

2007-07-15 Thread Birkin James Diana
-menu to show only cameras. In my model (for an 'Item' being digitized), I've defined a scanner field as: scanner = models.ForeignKey(Equipment, null=True, blank=True, limit_choices_to={'equipment_type__exact':'scan'}, related_name='scanner_set') ...and a camera field as: camera

complicated limit_choices_to on an inline-edited page

2007-07-12 Thread Charles Wesley
I have a ForeignKey field with the option: limit_choices_to = {'team__id': Game.objects.get(pk=1).visitor_team.id} This class is coded to be edited inline by another class. When I use the limit_choices_to option above, I can access the class directly, but not through the other class. When I

limit_choices_to confusion

2007-05-30 Thread Todd O'Bryan
I was trying to use limit_choices_to in what I thought was an intuitive way. class Organization(models.Model): members = ManyToManyField(User) class Committee(models.Model): org = ForeignKey(Organization) chair = ForeignKey( User, limit_choices_to

Re: Help with limit_choices_to

2007-05-15 Thread xgdlm
> At the moment, the easiest way I see to to that is to include a JS > file that will catch the current member_id, then call an external page > that will return a JSON string of > "Folder.objects.filter(member=member) " query_set and then build the > wished multiselected box .. I'll try that way

Re: Help with limit_choices_to

2007-05-14 Thread xgdlm
Hello Thank you Malcolm for your fast answer (as usual) > However, you > cannot pass parameters to that function: it's mostly for use with things > like datetime.datetime.now -- where the result of the function does not > depend on "self" in any fashion. Hum, that what I understood, but now I

Re: Help with limit_choices_to

2007-05-14 Thread Malcolm Tredinnick
On Mon, 2007-05-14 at 08:45 +, xgdlm wrote: > Hello all ! > > I have trouble using limit_choices_to on the following modele. I > searched the group and googled but I couldn't find the solution. > >

Help with limit_choices_to

2007-05-14 Thread xgdlm
Hello all ! I have trouble using limit_choices_to on the following modele. I searched the group and googled but I couldn't find the solution. Here is my modeles : - class Member(models.Model): login = models.CharField

Re: ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread quentinsf
Brilliant - thanks, Sam. Is this in the docs anywhere, I wonder? I've seen a few queries along these lines. Might be an FAQ Q --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread Sam Morris
On Mon, 19 Mar 2007 09:29:08 -0700, quentinsf wrote: > I need to do something similar. In a form I want to limit the options > in a ForeignKey's pull-down select field to objects owned by an > organisation of which the user is a member. > > I've been trying to work out where this would fit.

Re: ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread quentinsf
I need to do something similar. In a form I want to limit the options in a ForeignKey's pull-down select field to objects owned by an organisation of which the user is a member. I've been trying to work out where this would fit. Any help much appreciated.

ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread Sam Morris
Is it possible to use a ManyToManyField's limit_choices_to attribute to limit a user to picking only from related objects that have author = request.user? Given that request has no place in the model definition, would it be necessary to write a custom manipulator? -- Sam Morris http

Re: correct limit_choices_to syntax

2007-02-14 Thread Benedict Verheyen
Benedict Verheyen schreef: I now defined the fields in my custom change manipulator: self.fields = ( forms.PositiveIntegerField(field_name="Admissionnr", is_required=True), ... forms.SelectField(field_name="kamer", choices=room_choices), ... ) This displays the correct list of available

Re: correct limit_choices_to syntax

2007-02-13 Thread Benedict Verheyen
ScottB schreef: > I think you need to pass the actual values (i.e. the rooms), rather > than a function that returns them. Also 'id_in' needs two > underscores. So maybe: > > limit_choices_to = {'id__in': get_rooms()} > > Scott Indeed, i had already found out there was a

Re: correct limit_choices_to syntax

2007-02-13 Thread ScottB
On Feb 13, 8:06 am, Benedict Verheyen <[EMAIL PROTECTED]> wrote: > def get_rooms(): > return Room.objects.exclude(id__in=[patient.room.id for patient in > Patient.objects.filter(room__isnull=False)]) > I tried limit_choices_to = {'id_in': get_rooms} but this gives me: >

correct limit_choices_to syntax

2007-02-13 Thread Benedict Verheyen
be a dictionary This is the relevant code from my models.py def get_rooms(): return Room.objects.exclude(id__in=[patient.room.id for patient in Patient.objects.filter(room__isnull=False)]) class Patient(models.Model): room = models.ForeignKey(Room, blank=True, null=True, limit_choices_to

Re: limit_choices_to: getting access to current instance

2007-01-31 Thread qhfgva
form = animal_form() t = loader.get_template('tracker/animal_form.html') c = Context({ 'form': form, }) return HttpResponse(t.render(c)) If there is a way to do the above just using limit_choices_to, I'd still like to understand that method. Also if I'm doing anything particul

Re: limit_choices_to: getting access to current instance

2007-01-30 Thread quentinsf
I'm not quite sure if this is helpful - it's not a general solution on the ForeignKey specification so wouldn't work in admin, for example, but it worked for me with my own form... I was creating a view for a 'change' form. One parameter passed to the view (from the URL) was an organisation

Re: limit_choices_to: getting access to current instance

2007-01-30 Thread [EMAIL PROTECTED]
() limiters[id] = value return limiters The check for whether limit_choices_to is a callable() is what you need: the ability to have limit_choices_to evaluated at runtime rather than just an array stuck into the model that is checked against. If you look into the Django model API

Re: limit_choices_to: getting access to current instance

2007-01-29 Thread qhfgva
Thanks for the response. I'm not sure if this exactly covers my case but I like this feature. From the example given in the ticket: def assigned_tasks(): return get_assigned_tasks_id_list(blah, blah) class TimeRecord(models.Model): task = models.ForeignKey(Task, limit_choices_to

  1   2   >