求助:Django ORM问题
"Handle.Huang" <[email protected]> Mon, 21 Jan 2008 22:33:00 +0800
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
还是无法生成别的文件中的表,除了models.py的表被生成外,外部文件的表没有生成
文档结构如下:
G:.
│ manage.py
│ settings.py
│ settings.pyc
│ urls.py
│ urls.pyc
│ __init__.py
│ __init__.pyc
└─urus
│ models.py
│ models.pyc
│ views.py
│ __init__.py
│ __init__.pyc
│
└─db
log.py
log.pyc
__init__.py
__init__.pyc
以下是models.py
from django.db import models
from urus.db.log import log
# Create your models here.
class projects(models.Model):
name=models.CharField(maxlength=255,unique=True)
owner=models.CharField(maxlength=255,null=True)
urus/db/log.py
from django.db import models
class log(models.Model):
comments=models.CharField(maxlength=1000)
发件人: [email protected]
[mailto:[email protected]] 代表 vcc
发送时间: 2008年1月20日 23:15
收件人: [email protected]
主题: Re: [python-chinese] 答复: Django ORM问题
你用多少个文件定义模型都可以,但是你一定要在你的app目录下有一个models.py,因
为django只会load这个文件,然后在models.py里import其他文件里的模型,例如:
import models_1
import models_2
...
这样就可以工作了。
----- Original Message -----
From: Handle.Huang <mailto:[email protected]>
To: [email protected]
Sent: Sunday, January 20, 2008 10:46 PM
Subject: [python-chinese] 答复: Django ORM问题
如果使用默认的模型的话,那一个app就只有一个model.py,如果这个app有很多表的
话,难道所有的表都要定义在这个一个文件中,要是再加上自定义方法,这个文件将会
是很恐怖的,而且结构上也不好啊。
PS:
这个app已经在setting.py中已经定义了
_______________________________________________
python-chinese
Post: send [email protected]
Subscribe: send subscribe to [email protected]
Unsubscribe: send unsubscribe to [email protected]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
image001.png
(image/png, 18.1 KB) - not displayed