아래 파일이 있고 projectmanager라는 django 프로젝트의 일부인이 파일은 projectmanager/projects/models.py입니다. 파이썬 인터프리터를 사용하여 기능을 테스트하기 위해 프로젝트를 가져올 때마다 FileRepo()를 찾을 수 없다는 8 행의 이름 오류가 발생합니다. 이 수업을 올바르게 가져올 수 있습니까? 이상적으로 내가 찾고있는 것은 각 프로젝트에 각각 들어 있고 알려지지 않은 파일 수가 들어있는 여러 개의 FileRepos를 포함하는 것입니다. 사전에 도움을 주셔서 감사합니다.Python에서 동일한 파일 내의 다른 클래스로 클래스를 가져 오는 방법
#imports
from django.db import models
from django.contrib import admin
#Project is responsible for ensuring that each project contains all of the folders and file storage
#mechanisms a project needs, as well as a unique CCL#
class Project(models.Model):
ccl = models.CharField(max_length=30)
Techpacks = FileRepo()
COAS = FileRepo()
Shippingdocs = FileRepo()
POchemspecs = FileRepo()
Internalpos = FileRepo()
Finalreports = FileRepo()
Batchrecords = FileRepo()
RFPS = FileRepo()
Businessdev = FileRepo()
QA = FileRepo()
Updates = FileRepo()
def __unicode__(self):
return self.ccl
#ProjectFile is the file object used by each FileRepo component
class ProjectFile(models.Model):
file = models.FileField(uploadto='ProjectFiles')
def __unicode__(self):
return self.file
#FileRepo is the model for the "folders" to be used in a Project
class FileRepo(models.Model):
typeOf = models.CharField(max_length=30)
files = models.ManyToManyField(ProjectFile)
def __unicode__(self):
return self.typeOf
팁 주셔서 감사합니다. – Chris