python导入其他文件的类_如何将类导入Python中的同一文件中的其他类

我有以下文件,它是名为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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值