Reverse for 'add_product_to_order' with keyword arguments '{'args': (28,)}' not found. 1 pattern(s) tried: ['store/add_product_to_order/(?P<order_id>[^/]+)/add\\Z']

def home(request):

if request.method == "POST":

    user_id = request.POST.get('user-id-to-order')
    if user_id:
        user = User.objects.filter(pk=user_id).first()
        order = Order.objects.create(user=user, code=get_random_string(5))
        order.save()
        return redirect('store:add_product_to_order', args=(order.id,))

return render(request, 'store/home.html')

@login_required(login_url=‘/login’)
def add_products_to_order(request, order_id):

return HttpResponse(f'THis is the order which its id is {order_id}.')

When redirected to the next View rhe error(Reverse for ‘add_product_to_order’ with keyword arguments ‘{‘args’: (28,)}’ not found. 1 pattern(s) tried: [‘store/add_product_to_order/(?P<order_id>[^/]+)/add\Z’]) raised but if i type in the search bar '127.0.0.1.8000/store/add_product_to_order/28/add the error not diplayed and display the second view url

Please show the urls.py file in which this entry appears. Also identify what directory that urls.py file in in.

app_name = 'store'

urlpatterns = [
    path('', views.home, name='home'),
    path('add_product_to_order/<order_id>/add', views.add_products_to_order, name='add_product_to_order')
    
]

the urls.py in the app directory store

i want to tell you the the error displayed for the first time i posted request , if i reload the page with the same id it will be displayed

When posting code here, please enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted, which is critical with Python.
(Note, you don’t need to repost your code as another message, you can edit your previous post to include the ``` before and after that code.)

This is not the proper usage of the redirect function. See the docs at redirect, particularly example #2.

ok
so what is the sollution to this problem

Read the docs and change your use of the redirect function to the appropriate syntax.

use resolve_url

from django.shortcut import resolve_url, redirect

return redirect(resolve_url('store:add_product_to_order', order.id))