'function' object has no attribute 'owner'

Question:

error message 1
error message 2

@login_required
def topic(request, topic_id):
    topic = Topic.objects.get(id=topic_id)
    _check_topic_owner(request)

    entries = topic.entry_set.order_by('-date_added')
    context = {'topic': topic, "entries": entries}
    return render(request, 'learning_logs/topic.html', context)

def _check_topic_owner(request):
    if topic.owner != request.user:
        raise Http404

The problem is when im trying open page in web app. Is thow problem "’function’ object has no attribute ‘owner’"

Asked By: Zeratulez

||

Answers:

Try changing the name of the variable topic to a different name that doesn’t clash with the function called topic.

Answered By: Mouse
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.