from .models import Article, Comment
from django.contrib.auth.models import User
new_user = User.objects.create_user(username='swpp', password='iluvswpp') # Django default user model
new_article = Article(title='I Love SWPP!', content='Believe it or not', author=new_user)
new_article.save()
new_comment = Comment(article=new_article, content='Comment!', author=new_user)
new_comment.save()
Model을 올바르게 생성했는지 테스트하는 코드를 blog 디렉토리에서 실행시키니 첫 두 줄에서 error가 발생합니다.
from .models import Article, Comment의 경우
ModuleNotFoundError: No module named '__main_.models'; '__main_\' is not a package가 발생하며
from django.contrib.auth.models import User의 경우
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. 가 발생합니다.
from .models import Article, Comment from django.contrib.auth.models import User
new_user = User.objects.create_user(username='swpp', password='iluvswpp') # Django default user model new_article = Article(title='I Love SWPP!', content='Believe it or not', author=new_user) new_article.save() new_comment = Comment(article=new_article, content='Comment!', author=new_user) new_comment.save()
Model을 올바르게 생성했는지 테스트하는 코드를 blog 디렉토리에서 실행시키니 첫 두 줄에서 error가 발생합니다.
from .models import Article, Comment의 경우 ModuleNotFoundError: No module named '__main_.models'; '__main_\' is not a package가 발생하며
from django.contrib.auth.models import User의 경우 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. 가 발생합니다.
이 경우 어떻게 해결하여야 하나요?