populating a field based on selection of foreign key
I am working on a database project and I am facing a little challenge.
Here it is.
I have three tables defined as below:
class Generation(models.Model):
generation = models.CharField(max_length = 25)
def __unicode__(self):
return self.generation
class CogE(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
office_phone = models.CharField(max_length=15, blank=True)
mobile_phone = models.CharField(max_length=15, blank=True)
email = models.EmailField(blank=True)
def __unicode__(self):
return u'%s %s' % (self.first_name, self.last_name)
class System(models.Model):
system = models.CharField(max_length=30)
cog_E = models.ForeignKey(CogE)
project = models.ForeignKey(Project)
generation = models.ForeignKey(Generation)
def __unicode__(self):
return self.system
class Board(models.Model):
board = models.CharField(max_length=30)
sch_number = models.CharField(max_length=20, blank = True)
PWA_number = models.CharField(max_length=20, blank = True)
PWB_number = models.CharField(max_length=20, blank = True)
system = models.ForeignKey(System)
cog_E = models.ForeignKey(CogE)
generation = models.ForeignKey(Generation)
In the admin view I would like to the board generation field to be
populated based on the system entry (since generation is also a field
in the system table). Is this possible to do in django? Is the schema
correct (I know this is not really a django issue)? Any help is
greatly appreciated.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home