views:

85

answers:

1

I am using Multi-table inheritance for an object, and I need to limit the choices of the parent object foreign key references to only the rules that apply the child system.

from schedule.models import Event, Rule

class AirShowRule(Rule):
    """
    Inheritance of the schedule.Rule
    """
    rule_type = models.TextField(default='onAir')

class AirShow(Event):
    station = models.ForeignKey(Station)
    image = models.ImageField(upload_to='images/airshow', null=True, blank= True)
    thumb_image = models.ImageField(upload_to='images/airshow', null=True, blank= True)

Now, in the admin, I only want the AirShowRule(s) to be the choices for an AirShow(Event). What I get is all the rules that are in the schedule.event system.

I am inheriting from django-schedule found at http://code.google.com/p/django-schedule/

+1  A: 

I looked into the structure of the classes listed, and you should add this:

class AirShow(Event):
   ... your stuff...
   rule = models.ForeignKey(AirShowRule, null = True, blank = True,
                            verbose_name="VERBOSE NAME", help_text="HELP TEXT")

that should get everything straight (changed to "AirShowRule" from "Rule")

*you should also make sure that you implement AirShowRule more completely as I imagine you aren't overriding rule_type, and if you are, I don't think it'll do all that you want*

*see: models.py:23

...this line was taken from models.py:103 with the modification of the arguments: verbose___name & help_text (probably optional, but I'll leave that for you to inspect)

Be aware that I haven't used these modules before, but this should give you a push to keep going :)

Terence Honles
Thanks I am looking into this solution.
Steven H.
I was put on another issue, will get back to this one next week.
Steven H.