我有Document
模型:
class Document(models.Model):
user = models.ForeignKey(User)
title = models.CharField(max_length=255)
description = models.TextField()
content = models.TextField()
和DocumentRelation
型号:
class DocumentRelation(models.Model):
document_a = models.ForeignKey(Document,related_name='doc_a')
document_b = models.ForeignKey(Document,related_name='doc_b')
我有single_document
意见:
def single_document(request,id):
doc = Document.objects.get(id=id)
return render_to_response('single_file.html',{'doc':doc},context_instance=RequestContext(request))
在single_file.html
我有:
<a href="/add-relation/{{ doc.id }}" class="btn btn-success">Add related document</a>
我需要创建视图def add_relation(request,id):
。添加关系的最佳方法是什么?我需要预览要添加为相关的文档。如何解决?
(我问的是整体设计,怎么解决的)