Skip to content

Instantly share code, notes, and snippets.

@ohbargain
Created January 29, 2012 04:12
Show Gist options
  • Save ohbargain/1697118 to your computer and use it in GitHub Desktop.
Save ohbargain/1697118 to your computer and use it in GitHub Desktop.
Django Model Forward Declaration
class Quotations(models.Model):
quoted_date = models.DateField(verbose_name="Quoted Date")
price = models.FloatField(verbose_name="Quoted Price")
machine = models.ForeignKey('Machine', verbose_name = "Associated Machine")
def __unicode__(self):
return u"%s %s" %(self.machine.name,self.quoted_date,self.price)
class Machine(models.Model):
name = models.CharField(max_length = 30)
manufacturer = models.CharField(max_length = 30)
manufactued_date = models.DateTimeField(verbose_name="Date Manufactuered")
category = models.ForeignKey(MachineType,verbose_name = "category of machine")
quotation = models.ManyToManyField(Quotations,verbose_name="Quotations History")
def __unicode__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment