django:从现有模型创建新模型并在admin中显示

时间:2020-03-04 06:27:36

标签: django django-models django-admin

我现有的django项目的admin.py

from django.contrib import admin
from .models import ScholarProfile
admin.site.register(ScholarProfile)

models.py

class ScholarProfile(models.Model):
   author_name= models.CharField(max_length=100)
   profile_url= models.URLField(max_length=200, primary_key= True)
   Company= models.CharField(max_length=100, null=True)
   Website= models.CharField(max_length=100, null=True)
   publication_title= ArrayField(models.CharField(max_length=500))
   normalized_citations= ArrayField(models.CharField(max_length=50), null= True)
   citations= ArrayField(models.CharField(max_length=50), null= True)
   coAuthors= ArrayField(models.CharField(max_length=50), null= True)
   created_at= models.DateTimeField(auto_now_add= True)
   country= models.CharField(max_length=100, null= True)
   publications= models.CharField(max_length=100, null= True)
   Tcitations= models.CharField(max_length=100, null= True)
   Hindex= models.CharField(max_length=100, null= True)
   Gindex= models.CharField(max_length=100, null= True)
   Mindex= models.CharField(max_length=100, null= True)
   Oindex= models.CharField(max_length=100, null= True)
   Eindex= models.CharField(max_length=100, null= True)
   Hmedian= models.CharField(max_length=100, null= True)
   TNCc= models.CharField(max_length=100, default= '00', )
   Year= ArrayField(models.CharField(max_length=100), null=True)

   def __str__(self):
      return (self.author_name)

我想创建一个新模型,例如AuthorPublications,只包含上述类中的一些字段,例如CompanyYear。如何在新类中使用它们(继承他们。)此外,此新模型应该与上述模型的author_name(外键?)相关联

0 个答案:

没有答案