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
On 3/30/20 4:50 PM, aniket kamthe wrote:
Hey All,--I have been watching your youtube tutorials and have been stuck on an issue for a while now. Can you help me out pls -
I am trying to pass a parameter via a button in an HTML file and using that in the next link to access a specific set of entries from the database -
HTML File code -
{% 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 %}URLs files code -path('message/<int:threadid>/', views.message, name='message'),Views files codedef 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) But I get this error, idk how to resolve this one -
Pls let me know If you are able to figure out the problem.
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+unsubscribe@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.
No comments:
Post a Comment