Guest User

Untitled

a guest
Mar 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. from django.db import models
  2.  
  3. class Car(models.Model):
  4. manufacturer = models.ForeignKey(
  5. 'Manufacturer',
  6. on_delete=models.CASCADE,
  7. )
  8. # ...
  9.  
  10. class Manufacturer(models.Model):
  11. # ...
  12. pass
  13.  
  14. class PurchPurchaseAccount(models.Model):
  15. id = models.AutoField(primary_key=True)
  16. purchase = models.ForeignKey(PurchPurchase, null=True, db_column='purchase', blank=True, on_delete=models.CASCADE) # If "parent" rec gone, delete "child" rec!!!
  17. paid_from_acct = models.ForeignKey(PurchPaidFromAcct, null=True, db_column='paid_from_acct', blank=True, on_delete=models.PROTECT) # Disallow lookup deletion & do not delete this rec.
  18. _updated = models.DateTimeField()
  19. _updatedby = models.ForeignKey(Person, null=True, db_column='_updatedby', blank=True, related_name='acctupdated_by', on_delete=models.SET_NULL) # Person records shouldn't be deleted, but if they are, preserve this PurchPurchaseAccount entry, and just set this person to null.
  20.  
  21. def __unicode__(self):
  22. return str(self.paid_from_acct.display)
  23. class Meta:
  24. db_table = u'purch_purchase_account'
Add Comment
Please, Sign In to add comment