May-02-2019, 09:30 PM
I was watching a tutorial to django. I was using the cmd for some stuff. Anyways I have a class and I was trying to define the class but I was getting an error. TIA for your help
from django.db import models from django.utils import timezone from django.contrib.auth.models import User class Post(models.Model): title = models.CharField(max_length=100) content = models.TextField() date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE)
Error:Traceback (most recent call):
File "<console>", line 1, in <module>
File "C:\users\etc.\django\db\models\base.py", line 501n in __init__
raise TypeError("%s() got an unexpected keyword argument '%s'" % (cls.__name__, kwarg))
TypeError: Post() got an unexpected keyword argument 'author'