我正在学习python crash course, 2nd edition 第18章。做到激活模型需要makemigrations.
from django.db import models
# Create your models here.
class Topic(models.Model):
"""A topic the user is learning about."""
text = models.CharField(max_length=200)
date_added = models.DateTimeField(auto_now_add=True)
def __str__(self):
"""Return a string representation of the model."""
return self.text`
然后报错:
Traceback (most recent call last):
File "C:\Users\Dell-PC\learning_logs\models.py", line 6, in
class Topic(models.Model):
File "C:\Users\Dell-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\models\base.py", line 108, in new
app_config = apps.get_containing_app_config(module)
File "C:\Users\Dell-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\django\apps\registry.py", line 253, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\Dell-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\django\apps\registry.py", line 135, in check_apps_ready
settings.INSTALLED_APPS
File "C:\Users\Dell-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\django\conf_init_.py", line 82, in getattr
self.setup(name)
File "C:\Users\Dell-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\django\conf_init.py", line 63, in _setup
raise ImproperlyConfigured(
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.
[Finished in 383ms]
我用的是sublime text.
怎么解决?