Hi Wiley, I would say your data model -as you describe it- makes more sense if Dishes has a foreign key to Restaurants. Because it seems a typical dish (say mc_burger) can only be ordered in one restaurant (mcD). Then you don't need the foreign key Restaurants in IndividualMeals.
... However, this is debatable. It might not be the best data model if you want to scale things up later on (like add more dishes). See, you have double dishes (mc_fries AND bk_fries). That is redundant (if the dishes are equal). So maybe Restaurants should have a many2many relation with Dishes. Then you can specify which dishes can be ordered from which Restaurants. On the other hand, when you want to extend the information about the dishes, (a dish might have a price or a volume), you'll run into problems there. ... HTH dirk On 22-jun-2007, at 13:24, Wiley wrote: > > I'm a true novice programmer, brand new to django, but lovin' it so > far. I was wondering if there was any way to do something a little > tricky via the Admin classes that could help me not write a custom > view. > > Basically I'd love to do all my data entry from the Admin interface, > but I need to filter a set of choices on one Admin input interface > based on a choice I make further up the form. > > I live in a world with: > > 2 restaurants (McDonalds and Burger King) > 4 menu items, the same type of food at each restaurant (mc_burger, > mc_fries, bk_burger, bk_fries) > > Each time I eat at one of those restaurants I want to make a record of > the meal in my database. So I do the data entry through the django > Admin backend. If I select "Burger King" as the restaurant that I eat > my meal at, when it comes time to select the dishes I ate, I really > only want to see bk_fries and bk_burger, cuz I ate at BK and not > mickey D's. > > Can this be done just using the Admin class in models.py? > > Here's the sample code that I'm working with in model.py: > > class Restaurant(models.Model): > def __str__(self): > return self.name > > name = models.CharField('Restaurant Name', maxlength=200, blank=True) > class Admin: > fields = ( > ('Restaurant Name' , {'fields': ('name',)}), > ) > pass > > class Dishes(models.Model) > def __str__(self): > return self.name > > name = models.CharField('Restaurant Name', maxlength=200, blank=True) > class Admin: > fields = ( > ('Dish Name' , {'fields': ('name',)}), > ) > pass > > class IndividualMeal(models.Model): > def __str__(self): > return self.name > > restaurant_name = models.ForeignKey(Restaurant, > verbose_name="restaurant") > date_of_visit = models.DateTimeField('date of visit') > dishes = models.ManyToManyField(Dish, verbose_name="individual > dishes") > class Admin: > fields = ( > ('Restaurant Name' , {'fields': ('restaurant_name',)}), > ('Date of Visit', {'fields': ('date_of_visit',)}), > ('Dishes', {'fields': ('dishes',)}), > ) > pass > > > > > ----------------------------- Dirk van Oosterbosch de Wittenstraat 225 1052 AT Amsterdam the Netherlands http://labs.ixopusada.com ----------------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---