Fernando López
Fernando López

Reputation: 184

Django==3.0.7 FileNotFoundError

I know that no is the best way. But I want to know why not find the file. The path is ok. I dont understand that.

enter image description here

My views.py and urls.py: enter image description here

enter image description here

The archives path: enter image description here

Upvotes: 0

Views: 131

Answers (1)

Ben
Ben

Reputation: 2557

I believe you need to be more explicit in where the file exists:

def index(request):
    file_path = f"{settings.ROOT_DIR}/templates/index.html"
    archivo = open(file_path)
    template = Template(archivo.read())
    #[... continue]

Upvotes: 1

Related Questions