|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
django 创建应用程序,定义模型时候,models.py报错,请教下大家这是什么原因,搞了好久没搞懂
代码:
from django.db import models
# Create your models here. 定义模型
class Topic(models.Model):
"""用户学习的主题"""
text = models.CharField(max_length = 200)
data_added = models.DateTimeField(auto_now_add = True)
def __str__(self):
"""返回模型的字符串表示"""
return self.text
报错:
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============== RESTART: F:\python test\learning_logs\models.py ==============
Traceback (most recent call last):
File "F:\python test\learning_logs\models.py", line 5, in <module>
class Topic(models.Model):
File "D:\Python\lib\site-packages\django\db\models\base.py", line 87, in __new__
app_config = apps.get_containing_app_config(module)
File "D:\Python\lib\site-packages\django\apps\registry.py", line 249, in get_containing_app_config
self.check_apps_ready()
File "D:\Python\lib\site-packages\django\apps\registry.py", line 131, in check_apps_ready
settings.INSTALLED_APPS
File "D:\Python\lib\site-packages\django\conf\__init__.py", line 57, in __getattr__
self._setup(name)
File "D:\Python\lib\site-packages\django\conf\__init__.py", line 42, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
求助求助,先感谢大家 |
|