Pie*_*oni 4 django many-to-many django-models
我正在写一个小网站来存储我写的文件.关系论文< - >作者很重要,但作者姓名的顺序(哪一个是第一作者,哪一个是二阶,依此类推)也很重要.
我只是在学习Django,所以我不太了解.无论如何,到目前为止,我已经完成了:
from django.db import models
class author(models.Model):
Name = models.CharField(max_length=60)
URLField = models.URLField(verify_exists=True, null=True, blank=True)
def __unicode__(self):
return self.Name
class topic(models.Model):
TopicName = models.CharField(max_length=60)
def __unicode__(self):
return self.TopicName
class publication(models.Model):
Title = models.CharField(max_length=100)
Authors = models.ManyToManyField(author, null=True, blank=True)
Content = models.TextField()
Notes = models.TextField(blank=True)
Abstract = models.TextField(blank=True)
pub_date = models.DateField('date published')
TimeInsertion = models.DateTimeField(auto_now=True)
URLField = models.URLField(verify_exists=True,null=True, blank=True)
Topic = models.ManyToManyField(topic, null=True, blank=True)
def __unicode__(self):
return self.Title
Run Code Online (Sandbox Code Playgroud)
这项工作很好,我现在可以定义作者是谁.但我无法订购它们.我该怎么办?
当然,我可以添加一系列关系:第一作者,第二作者,......但它会很难看,而且不会灵活.有什么好主意吗?
谢谢
| 归档时间: |
|
| 查看次数: |
3002 次 |
| 最近记录: |