0

Hi im new to coding and django and im trying to create a simple e-commerce website but when clicking a button to redirect to cart but it is not going through. this error comes up when i initiate the server.


     File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\sre_parse.py", line 831, in _parse
        raise source.error(err.msg, len(name) + 1) from None
    re.error: redefinition of group name 'id' as group 2; was group 1 at position 25

here is the html code

            <!-- Product Pricing -->
            <div class="product-price">
              <span>{{i.product_price}}</span>
              <a href="/cart/{{i.id}}/{{customer.id}}" class="cart-btn">Add to cart</a>
              <p>{{customer.id}}</p>
              <a href="" class="cart-btn">go to cart</a>
            </div>
   

my views code


    def cart(request,cid,pid) :
        p_info=product_info.objects.get(id=pid)
        c_info=login_details.objects.get(id=cid)
        return render(request, 'customer side/cart.html')

my appurl code



    urlpatterns=[
        path('register',views.save_login_info),
        path('cart/<int:id>/<int:id>/',views.cart),
        path('login',views.logging_in,name='login'),
        path('list',views.product_catalogue),
        path('new',views.add_product),
        path('savingdata',views.addnew,name='saving'),
    
        enter code here
    
    ]

``

the error apppears to have something to do with the url part of the cart when i remove on of the integer id from cart/int(id)/int(id) the error disappears but i need both numbers.
i tried assigning values to the variables in my views code but nothing seems to fix the problem.
please help.

2

1 Answer 1

0

You're asking for two arguments called ID and once the redirect happens, the second ID overwrites the first one. Just change the second one to customer_id or something and that will clear up your issue.

  urlpatterns=[
        path('register',views.save_login_info),
        path('cart/<int:product_id>/<int:customer_id>/',views.cart),
        path('login',views.logging_in,name='login'),
        path('list',views.product_catalogue),
        path('new',views.add_product),
        path('savingdata',views.addnew,name='saving'),
    
    ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.