CoreyMSchafer/code_snippets

i got this error messages when attempting to make a post, please i need help. thanks

Closed this issue · 0 comments

ValueError at /post/new/
Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x04CF38E0>>": "post.author" must be a "User" instance.

def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)