Is it possible to force a base model to have a sub model? Consider the
following model...

class Account(models.Model):
    user        = models.ForeignKey('auth.User')
    name        = models.CharField(max_length=100)
    description = models.CharField(max_length=35, blank=True)
    date_added  = models.DateField(auto_now_add=True, blank=True)

class CheckingAccount(Account):
    routing_number = models.IntegerField(max_length=9)
    account_number = models.IntegerField(max_length=15)

class CreditCardAccount(Account):
    type   = models.CharField(max_length=1)
    number = models.IntegerField(max_length=16)
    exp    = models.CharField(max_length=5)

class Payment(models.Model):
    account     = models.ForeignKey(Account)
    date_billed = models.DateField()
    date_paid   = models.DateField(blank=True)
    amount      = models.DecimalField(max_digits=10, decimal_places=2)

I want to require that the Payment model have an Account. That works
fine, but I want that account to either be a CreditCardAccount or
CheckingAccount. Right now in the admin interface when I view the
Payment form I get the opportunity to add an Account. That is fine but
it means nothing without a relationship with CreditCardAccount or
CheckingAccount.

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