Hi @ashishmani - your post did indeed trip the spam filter. Someone usually gets to it within 12 hours, so I got to it this morning and approved everything, but in cases like this, it’s best to wait a little until one of us can do it.
So yes, you’re rendering a url using the name mobile
, but you do not have a url defined using that name.
urls.py
from django.views.generic import base
from app import views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('',views.ProductView.as_view(),name="home"),
path('product-detail/<int:pk>', views.ProductDetailView.as_view(), name='product-detail'),
path('cart/', views.add_to_cart, name='add-to-cart'),
path('buy/', views.buy_now, name='buy-now'),
path('profile/', views.profile, name='profile'),
path('address/', views.address, name='address'),
path('orders/', views.orders, name='orders'),
path('changepassword/', views.change_password, name='changepassword'),
path('mobile/<slug:data>', views.mobile, name='Mobiledata'),
path('login/', views.login, name='login'),
path('registration/', views.customerregistration, name='customerregistration'),
path('checkout/', views.checkout, name='checkout'),
] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) ```
views.py
```from django.shortcuts import render
from django.views import View
from .models import Customer,Product,Cart,OrderPlaced
# def home(request):
# return render(request, 'app/home.html')
class ProductView(View):
def get(self,request):
topwears=Product.objects.filter(category='TW')
bottomwears=Product.objects.filter(category='BW')
mobiles=Product.objects.filter(category='M')
return render(request,'app/home.html/',
{'topwear':topwears,'bottomwears':bottomwears,'mobiles':mobiles})
# def product_detail(request):
# return render(request, 'app/productdetail.html')
class ProductDetailView(View):
def get(self,request,pk):
product=Product.objects.get(pk=pk)
return render(request,'app/productdetail.html',{'product':product})
def add_to_cart(request):
return render(request, 'app/addtocart.html')
def buy_now(request):
return render(request, 'app/buynow.html')
def profile(request):
return render(request, 'app/profile.html')
def address(request):
return render(request, 'app/address.html')
def orders(request):
return render(request, 'app/orders.html')
def change_password(request):
return render(request, 'app/changepassword.html')
def mobile(request, data=None):
if data == None:
mobiles=Product.objects.filter(category='M')
elif data=='Redmi'or data=='Samsung':
mobiles=Product.objects.filter(category='M').filter(brand=data)
elif data=='below':
mobiles=Product.objects.filter(category='M').filter(discounted_price__lt=10000)
elif data=='above':
mobiles=Product.objects.filter(category='M').filter(discounted_price__gt=10000)
return render(request, 'app/mobile.html',{'mobiles':mobiles})
def login(request):
return render(request, 'app/login.html')
def customerregistration(request):
return render(request, 'app/customerregistration.html')
def checkout(request):
return render(request, 'app/checkout.html')```
I’m not sure I understand why you’re reposting this code. I can’t point out something wrong in something that’s not there. The issue isn’t what you have, it’s what you don’t have - and that’s a url defined with the name mobile
.
(Also, remember that the three backtick characters must be on a line by themselves.)
you plz explain me ‘reverse for mobile not found’, in which conditions such problems accured?