2013-03-02 3 views
1

안녕하세요 내가 template.I 장고에 새로운 오전 HTML에서 하나의 순서로이 두 테이블을 표시 waant이디스플레이 여러 관련 장고 모델은

from django.db import models 

class Book(models.Model): 
    book_id=models.AutoField(primary_key=True,unique=True) 
    book_name=models.CharField(max_length=30) 
    author_name=models.CharField(max_length=30) 
    publisher_name=models.CharField(max_length=40) 
    def __unicode__(self): 
     return "%d %s %s %s" % (self.book_id,self.book_name, self.author_name,self.publisher_name) 


class Author(models.Model): 
    author_id=models.AutoField(primary_key=True) 
    first_name = models.CharField(max_length=30) 
    last_name = models.CharField(max_length=40) 
    email = models.EmailField() 
    age=models.IntegerField() 
    book=models.ForeignKey(Book) 

    def __unicode__(self): 
     return u'%d %s %s' % (self.author_id,self.first_name, self.last_name) 

같은 models.py를 데. .I는 views.py의 디자인과 "htmlfile.html 템플릿".Plz도

+0

는 대답을 http://stackoverflow.com/questions/15173251/retrieve-data-from-two-tables-with-foreign- 키 - 관계 -에 - 장고를 최신 질문을 확인 – gangakvp

답변