Open Minji1234 opened 5 years ago
You should import User
as
from django.contrib.auth.models import User
since we are using the default django User model 🙂
Thanks for your replying. Actually I wrote 'from django.contrib.auth.models import User' in the models.py. (not implemented, just imported) So in this case, delete that line from models.py and running following lines in repository_root by 'python manage.py shell' is right implementation?
from blog.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()
Thank you again!
I want to check if I created right model, so I used following lines by "python manage.py shell" at repository_root(as there was no manage.py in 'blog' directory, I tested it in 'repository_root' directory)
from .models import Article, Comment
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()
But it created some errors so I had to run following lines
from blog.models import Article, Comment, 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()
I'm questioning because my model didn't work as explained in README.md. Did I made mistakes?