我有以下文件,它是名为projectmanager的django项目的一部分,此文件为projectmanager/projects/models.py。每当我使用Python解释器来导入一个项目只是为了测试功能,我得到了第8行的名称错误,无法找到FileRepo()。如何正确导入这些类?理想情况下,我正在寻找的是每个Project包含多个FileRepos,每个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
2010-05-19
Chris