On Thursday 31 August 2006 14:03, bk wrote:
> class CategoryPhoto(models.Model):
>   category = models.ForeingKey(Category, edit_inline=models.Tabular)
>   position = models.PositiveIntegerField(core=True)
>   photo = models.ForeignKey(Photo, limit_choices_to={'category__pk':
> ???})
>
> ??? is where I basically want to use the id of the current category
> being edited to limit the photo choices to those set for that
> category - since there's over 100 records in the db so far.
>
> Any chance this would be possible with a similar Q class?

I don't think this will be possible, if I understand correctly. 
The 'limit_choices_to' parameter simply alters the query that is used 
to get the list of photos used to populate the drop down list.  This 
query is completely independent of which CategoryPhoto is being 
edited - in fact, when adding a CategoryPhoto object (as opposed to 
editing), the object doesn't even exist in the database, but the photo 
drop down still needs to be populated.

The only way I can recommend is to add some AJAX that responds to 
changes to the category drop and repopulates the photo drop down 
accordingly.  Thankfully this should be pretty easy using the 'js' 
admin option.

Luke

-- 
"Pessimism: Every dark cloud has a silver lining, but lightning kills 
hundreds of people each year trying to find it." (despair.com)

Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to