1
自動的にクエリセットから返された私は、私はitem.senderが自動的私はアイテムが
にハイパーリンクするのが好きdはモデル 私は<li>{{ item.sender }} {{ item.receiver }} {{ item.amount }}</li>
を使用して表示
class Transaction(models.Model):
sender = models.ForeignKey(MyBankAccount, unique=False, related_name="transactions_sent")
receiver = models.ForeignKey(RecipientBankAccount, unique=False, related_name="transactions_received")
created = models.DateField('transfer request date')
amount = models.FloatField()
createdby=models.ForeignKey(User,null=True)
を持ってどのようにハイパーリンクします
http://example.com/johnsmith/trans/ここで、johnsmithはトランザクションを作成するユーザーの名前です(別名createdby)。私はすでにこのURLのビューを実装しました。私はちょうどそれにリンクする必要があります。
ハイパーリンクのテキストコンポーネントに任意のものを置くことができます。リンクジェネレータ自体については、名前がアカウントの一意の識別子である限り、はい。そうでなければ、 "get()のために返された複数の行"に関するかなり標準的なエラーが発生します。 –