NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' not found. 1 pattern(s) tried: ['add_comment/$']
The code for the relevant part of the HTML document is as follows:
<h2>comments</h2>
{% if not comments %}
No comments
{% endif %}
{% for x in comment %}
<div class="comments" style="padding: 10px;">
<p class="font-weight-bold">
<h4>Comment by</h4> {{ x.user }}
<span class=" text-muted font-weight-normal">
{{ x.created_on }}
</span>
</p>
{{ x.body | linebreaks }}
</div>
{% endfor %}
</div>
<div class="card-body">
{% if new_comment %}
<h2>Your comment has been posted.</h2>
{% else %}
<h3>Leave a comment</h3>
<form action="{% url 'nowandthen:add_comment' image.id %}" method="POST">
{{ comment_form.as_p }}
{% csrf_token %}
<button type="submit" class="btn btn-primary btn-lg">Submit</button>
{% endif %}
The URLs.py entry for add_comment is path('add_comment/<int: image_id>', views.add_comment, name='add_comment'). Removing the int: image_id doesn't fix the problem.
When I go into admin, no ids appear to have been generated for the photos. Could it be that the problem is that there are missing IDs? If so, how do I fix this?
The repository URL is https://github.com/EmilyQuimby/my_now_and_then.
Thank you.
I've just tried that, but I still get an error message.
By the way, is it definitely .id and not _id? I've seen both, and Django docs says: 'Behind the scenes, Django appends "_id" to the field name to create its database column name, which makes me wonder if it might be _id.
Incidentally, I've also tried amending the relevant URL path to path('add_comment/<int:p.image_id>', views.add_comment, name='add_comment') - with underscore and with a dot before the id - but that doesn't work.
Jeff
--
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/4473f031-abfa-428a-8804-debaf5a41c93%40googlegroups.com.