Update: I wanted to post the resolution to this in case anyone in the future 
finds this post and can't find an answer (like the many I found). 

In my battle with this, I was able to accomplish this using 
django-smart-selects. 
https://github.com/digi604/django-smart-selects 



----- Original Message -----

From: "Kristofer" <kristo...@cybernetik.net> 
To: django-users@googlegroups.com 
Sent: Wednesday, January 9, 2013 12:49:28 AM 
Subject: Admin and ForeignKey 

Hello, 

I have three models, defined like the following (code below simplified): 

class Shirt(Model): 
sku = CharField() 
description = CharField() 

class Color(Model) 
name = CharField() 
shirt = ForeignKey(Shirt) 
price = Decimal() 

class Order(Model) 
shirt = ForeignKey(Shirt) 
color = ForeignKey(Color) 

The admin page for shirt shows Color options inline, so that the name and price 
can be typed in. 

My views for the order form from customers are set so that only the appropriate 
colors are displayed for the shirt selected. 

However, in the Admin Order page, the Color field shows all of the colors for 
all shirts. How can I restrict the Color field to only show colors where the 
Color.Shirt foreignkey matches the Order.Shirt foreignkey? 



-- 
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 
django-users+unsubscr...@googlegroups.com. 
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en. 

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to