Re: NoReverseMatch error message - Please help
Sometimes the error can be from your url.py or even views.py and also make sure no typo. Check each on e of the above carefully. Hopefully you might see the bug. Cheers On Tue 31. Mar 2020 at 18.06, Jeff Waters wrote: > Thanks Ryan. > > 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/', 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+unsubscr...@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 > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAipwd_Bjw%2BajNSVfyKcO5f27i2oxEmHoppnun2sA399eqcVxg%40mail.gmail.com.
Re: NoReverseMatch error message - Please help
Thanks Ryan. 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/', 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+unsubscr...@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.
Re: NoReverseMatch error message - Please help
Based on the rest of your template from the github link, looks like: {% url 'nowandthen:add_comment' image.id %} ...should instead be: {% url 'nowandthen:add_comment' p.image.id %} On 3/31/20 7:08 AM, Jeff Waters wrote: I am putting together a website which has a photo gallery where users can add comments. When I go to the photo gallery page, I get the following error message: 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: comments {% if not comments %} No comments {% endif %} {% for x in comment %} Comment by {{ x.user }} {{ x.created_on }} {{ x.body | linebreaks }} {% endfor %} {% if new_comment %} Your comment has been posted. {% else %} Leave a comment {{ comment_form.as_p }} {% csrf_token %} Submit {% endif %} The URLs.py entry for add_comment is path('add_comment/', 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. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6e0854a3-ae89-d1a7-8fcf-98fbbadc9a3e%40fattuba.com.
Re: NoReverseMatch error message - Please help
Hi Jeff, On 31/03/2020 14.08, Jeff Waters wrote: I am putting together a website which has a photo gallery where users can add comments. When I go to the photo gallery page, I get the following error message: NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' not found. 1 pattern(s) tried: ['add_comment/$'] Trailing slashes are part of the path, so "/foobar/" is not the same as "/foobar". Hopefully that should give you a hint to what is most likely the cause of your problem. Kind regards, Kasper Laudrup -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/860f1f56-b008-f38b-3b01-8ff985f5d88f%40stacktrace.dk.
NoReverseMatch error message - Please help
I am putting together a website which has a photo gallery where users can add comments. When I go to the photo gallery page, I get the following error message: 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: comments {% if not comments %} No comments {% endif %} {% for x in comment %} Comment by {{ x.user }} {{ x.created_on }} {{ x.body | linebreaks }} {% endfor %} {% if new_comment %} Your comment has been posted. {% else %} Leave a comment {{ comment_form.as_p }} {% csrf_token %} Submit {% endif %} The URLs.py entry for add_comment is path('add_comment/', 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. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bb078990-f0e1-484a-a3dc-366f018b1df6%40googlegroups.com.