My issue is that every time i run the server with this code i get a : TypeError at /playground/hello/
hello() missing 1 required positional argument: ‘product_id’
this happened after i added info1 and info2 in the views folder because before it wasn’t recognizing product_id in the html file and was giving me a NoReverseError
Any help would be greatly appreciated
It looks like your
hello view/function requires a
product_id parameter, but based on your
urlpatterns it looks like you’re not passing a
product_id along. And if you did include the product ID in the URL it seems like you would hit your
detail view instead.
So how would I fix it because if i remove the parameter it gives me a NoReverseMatch error with this Reverse for ‘information’ with arguments ‘(’’,)’ not found. 1 pattern(s) tried: [‘playground/hello/(?P<product_id>[0-9]+)\Z’]
Thank you for your help i really appreciate it
Do you have a screenshot of the
Maybe you could try some different URL patterns for troubleshooting. For example, instead of
hello/<int:product_id>/ maybe try
products/<int:product_id>/ which might prevent
hello requests from hitting your
This is the NoReverseMatch error ill try the different url patterns to see if it’ll work with some changes. I basically want it to work like if i click the “button”(not like an actual button class or anything like that just the url link in the table of index.html) it goes to the detail.html view per product based on the product id of the selected product. Sorry if that wasn’t worded well! Thank you again!
Alright so I tried changing the url patterns and it still led me to the same issues i tried using ur example as well as a couple other combinations such as changing names and such but I still run into the same issue the hello() missing 1 required positional argument: ‘product_id’ error still occurs and if i remove the info 1 and 2 to return it to the state it was in before it gives me a NoReverseError like above
NoReverseMatch problem, is it possible that the
product_id on line 17 of index.html is missing e.g. an empty string instead of an integer?
Thats what i’m assuming the issue but essentially because the homepage per say in this question doesn’t have a number at the last / for the url it just returns an empty string but I’m stumped on how to essentially make the variable usable but not a necessary factor for entering the page