essykings/django_cms

TypeError at /stories/ while running this project

Opened this issue · 0 comments

Hi Esther,

I get into some troubles while I git clone your code from https://github.com/essykings/django_cms, and then:

python manage.py makemigrations

python manage.py migrate

 python manage.py runserver

But when I visit http://localhost:8000/add, it reports that 404 Not Found.

So I put a slash after the cms/urls.py:

urlpatterns = [

    path('add/',add_stories, name = "add_story"),

    path('stories/', stories, name = "stories"),

]

And now, I can visit http://localhost:8000/add successfully.

But it ran into another error while I visit http://127.0.0.1:8000/stories/ which raises error:

django_cms\cms\views.py", line 27, in stories
    posts = Story.objects.filter(author =request.user)

TypeError at /stories/
Field 'id' expected a number but got <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x000001F1917B2550>>.

How should I do now? I've searched for Google in the whole night but find no answer.

Please help me! Looking forward to your reply.

Caesar