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


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

Reply via email to