{% for thread in object %}
<tr>
<td><a href="{% url 'message' thread.id %}" class="btn btn-primary" role="button">{{ thread.name }}</a></td>
<td>Something</td>
</tr>
{% endfor %}
path('message/<int:threadid>/', views.message, name='message'),
def message(request, threadid):
if request.method == 'POST':
print(request.POST.get('message'))
m = messages(message=request.POST.get('message'), thread_id='00', likes='00', Message_flags='00')
m.save();
if (request.method == 'POST') and ("like" in request.POST):
print("hi")
data = messages.objects.all()
context = {
'object': data
}
return render(request, 'mysite/message.html', context)
else:
data = messages.objects.all()
context = {
'object': data
}
return render(request, 'mysite/message.html', context)
Hi Aniket,
Your thread object in your template is actually a message since your passing messages to context in your view.
but when you initialize messages you don't set a name attribute.
So I would double check your Message model if it has a name attribute.
btw your error message didn't display for me.
Antje
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/deae3154-4d36-438a-9669-5698d319ed27%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/879b4154-a801-9080-96a3-0f28e5e38ac1%40gmail.com.