Django özel decorators yazmak. Django decorator örneği.

Django 148 views Markdown
def test_decorators(function):
    def wrap(request, *args, **kwargs):
 
        id = kwargs.get('id', None)
        productid = kwargs.get('productid', None)
        producttype = kwargs.get('producttype', None)
 
        print(request, id, productid, producttype)
 
        if productid:
            product = Product.objects.get(id=productid)
            print(product)
 
        return function(request, *args, **kwargs)
 
    return wrap
 
 
@login_required
@test_decorators
def basket_add(request, productid, producttype):
    ...
    ...
 
 
@login_required
@test_decorators
def basket_remove(request, id):
    ...
    ...
    
    

 

 

 

 

Was this helpful?

Thanks for your feedback!

Still Need Help?

The support team is here around the clock for anything you can't find in the knowledge base.