This has nothing to do with your render statement itself. It’s an issue of what you’re rendering.
We need to see the template being rendered.
Also, when you’re posting code, please enclose it between lines consisting of three backtick - ` characters. This means you’ll have one line of ```, then your code, then another line of ```. This allows the forum to properly format your code and prevents special characters from being replaced.
sir i’m getting this error as Reverse for ‘restaurant_page_for_order’ not found. ‘restaurant_page_for_order’ is not a valid view function or pattern name
here is my urls
urlpatterns = [
path(‘admin/’, admin.site.urls),
path(’’,include(‘app.urls’)),
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
When you post code here, please enclose it between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This directs the forum software to keep your code formatted properly.
Assuming that this isn’t an issue caused by your code being mangled by the forum software, the issue is that you have a url named ‘rest_for_order’, not ‘restaurant_page_for_order’.
sir i’m getting this error as Reverse for ‘rest_for_order’ with no arguments not found. 1 pattern(s) tried: [‘rest_for_order/(?P[^/]+)$’]
here is my urls’’’
urlpatterns = [
path(‘admin/’, admin.site.urls),
path(’’,include(‘app.urls’)),
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
‘’’
my app.urls
path(‘home_for_order’, home_for_order, name=‘home_for_order’),
path(‘rest_for_order/str:slug’, rest_for_order, name=‘rest_for_order’),
path(‘cart/str:slug’, cart, name=‘cart’),
path(‘myorders’,myorders,name=‘myorders’),
path(‘savedetails’, savedetails, name=‘savedetails’),
blog.slug is either null or blank. It’s finding the url named blogdetail, but that url requires an argument passed to it. Your template has such an argument defined (blog.slug), but if it’s null or a zero-length string (""), it doesn’t pass the test of being a <slug>.
Hmm. I see a context['blog_obj'] = blog_obj in the view, but I see the variable being looped over as blogs. I agree with Ken, it looks like blog.slug doesn’t exist and that’s the cause of this.
Please post your Blog object (the definition for it in your models.py file). Is the slug attribute a field in the object, or is it a method?
If it’s a field in the object, from the shell you can do something like: [(b.id, b.slug) for b in Blog.objects.all()]
to see the primary key and slug fields for every Blog object to ensure none of them are blank.
If slug is a model method, you would do something like this: [(b.id, b.slug()) for b in Blog.objects.all()]