幫忙看看這段代碼那里錯了
from?django.http?import?HttpResponse from?blog.models?import?Article def?hello_world(request): ????return?HttpResponse("hello?world?????") def?article_content(request): ????article?=?Article.objects.all()[0] ????title?=?article.title ????brief_content?=?article.brief_content ????content?=?article.content ????article_id?=?article.article_id ????publish_date?=?article.publish_date ????return_str?=?'title:?%s,?brief_content:?%s,?'?\ ?????????????????'content:?%s,?article_id:?%s,?publish_date:?%s'?%?(title, ????????????????????????????????????????????????????????????????????brief_content, ????????????????????????????????????????????????????????????????????content, ????????????????????????????????????????????????????????????????????article_id, ????????????????????????????????????????????????????????????????????publish_date) ????return?HttpResponse(return_str)
運行這段veiws.py,報錯
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.
2020-11-10
django是個框架,需要從manage.py來runserver跑服務,不然會缺少一些必要的環境變量
view.py不能直接run的