Anybody? On Aug 1, 2:49 pm, Greg <[EMAIL PROTECTED]> wrote: > Ok..does anybody know what's wrong with this attempt at trying to get > the 'limit-choices_to' to work? > > class Choice(models.Model): > choice = models.ForeignKey(Collection, edit_inline=models.TABULAR, > num_in_admin=5) > size = models.ForeignKey(Size, core=True) > price = models.ForeignKey(Price, core=True) > > class Style(models.Model): > name = models.CharField(maxlength=200, core=True) > color = models.CharField(maxlength=100) > image = models.ImageField(upload_to='site_media/') > theslug = models.SlugField(prepopulate_from=('name',)) > manufacturer = models.ForeignKey(Manufacturer) > sandp = models.ManyToManyField(Choice, limit_choices_to = > {'choice': get_choices(self)}) > collection = models.ForeignKey(Collection, > edit_inline=models.TABULAR, num_in_admin=6) > > def get_choices(self, style_name): > g = Choice.objects.filter(pk=style_name.collection) > return g > > Thanks > > On Aug 1, 11:09 am, Greg <[EMAIL PROTECTED]> wrote: > > > We'll I kinda got it to work. I added the following > > (limit_choice_to): > > sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': > > 2}) > > > /////////////////////// > > > That works fine. However, I obviously want to take out the '2'. I > > tried the following but it does not seem to work: > > sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': > > collection.id}) > > > //////////// > > > I guess I need to know how do I get the id for the current collection > > that I'm adding the style to? > > > Thanks > > > On Aug 1, 2:17 am, Will McCutchen <[EMAIL PROTECTED]> wrote: > > > > > Is there anyway that I can have the 'sandp' Field only > > > > show choices that are tied to that collection? > > > > Try using the limit_choices_to argument to > > > ManyToManyField:http://www.djangoproject.com/documentation/model-api/#many-to-many-re... > > > > Hope this helps, > > > > Will.
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---