# 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'\]

**URL:** <https://forum.djangoproject.com/t/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/17900>\
**Category:** Forms & APIs\
**Created:** [December 29, 2022, 11:35am UTC](https://forum.djangoproject.com/t/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/17900 "2022-12-29T11:35:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![moaz890](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moaz890/32/10513_2.png) [@moaz890](https://forum.djangoproject.com/u/moaz890)\
**Post date:** [December 29, 2022, 11:35am UTC](https://forum.djangoproject.com/t/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/17900/1 "2022-12-29T11:35:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 29, 2022, 11:43am UTC](https://forum.djangoproject.com/t/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/17900/2 "2022-12-29T11:43:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moaz890](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moaz890/32/10513_2.png) [@moaz890](https://forum.djangoproject.com/u/moaz890)\
**Post date:** [December 29, 2022, 11:46am UTC](https://forum.djangoproject.com/t/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/17900/3 "2022-12-29T11:46:20Z")

</div>

```auto
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

---

<div class="post-metadata">

**Author:** ![moaz890](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moaz890/32/10513_2.png) [@moaz890](https://forum.djangoproject.com/u/moaz890)\
**Post date:** [December 29, 2022, 11:51am UTC](https://forum.djangoproject.com/t/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/17900/4 "2022-12-29T11:51:27Z")

</div>

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

 ![error-dj](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/9/94ae8b0d426d705d71e3b180ddc62a575ac5806d.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 29, 2022, 12:14pm UTC](https://forum.djangoproject.com/t/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/17900/5 "2022-12-29T12:14:23Z")

</div>

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.)

> [@moaz890](#):
>
> `return redirect('store:add_product_to_order', args=(order.id,))`

This is not the proper usage of the `redirect` function. See the docs at [redirect](https://docs.djangoproject.com/en/4.1/topics/http/shortcuts/#redirect), particularly example #2.

---

<div class="post-metadata">

**Author:** ![moaz890](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moaz890/32/10513_2.png) [@moaz890](https://forum.djangoproject.com/u/moaz890)\
**Post date:** [December 29, 2022, 12:23pm UTC](https://forum.djangoproject.com/t/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/17900/6 "2022-12-29T12:23:42Z")

</div>

ok  
so what is the sollution to this problem

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 29, 2022, 3:53pm UTC](https://forum.djangoproject.com/t/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/17900/7 "2022-12-29T15:53:05Z")

</div>

> [@moaz890](#):
>
> so what is the sollution to this problem

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

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 8, 2024, 1:12am UTC](https://forum.djangoproject.com/t/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/17900/9 "2024-08-08T01:12:10Z")

</div>

use resolve\_url

```auto
from django.shortcut import resolve_url, redirect

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

```
