0

I'm creating a view from my Django app that's suppose to call a template in my app directory called rooms. My app's name is room. When I write the code

return render(request, 'base\room.html', context)

I get an error at \r and the page doesn't load. Mind you, changing the template name to anything other than it starting without an r works fine. So, 'base\loom.html' works. Any idea why this is so? I only started noticing this recently

iKay
  • 11
  • 1

1 Answers1

0

if you inherited room.html with base.html then go with this code

return render(request, 'room.html', context)

if you have not inherited room.html with base.html then go with this code

return render(request, 'base/room.html', context)
  • Because the template this is referring to is in the app's template directory, using just 'room.html' won't work. But using forward slashes fixed the issue for me. Thanks! – iKay Sep 26 '22 at 16:03