mvc-flask icon indicating copy to clipboard operation
mvc-flask copied to clipboard

jinja2.exceptions.TemplateNotFound: index.html

Open bjenmonk opened this issue 3 years ago • 24 comments

Hi I cloned your code and while trying to use the example app I am getting this error

raise TemplateNotFound(template)

jinja2.exceptions.TemplateNotFound: index.html

I tried creating a templates folder under the example directory and copied contents from the view folder to it. still the same error

Appreciate your help

bjenmonk avatar Sep 06 '21 00:09 bjenmonk

Hi @bjenmonk ,

change the folder name templates to views . let me know if i helped you

marcuxyz avatar Sep 06 '21 00:09 marcuxyz

Hi Marcuxyz tried that but didn't worked so I fixed it by changing def create_app(): app = Flask(name, template_folder='views')

bjenmonk avatar Sep 06 '21 00:09 bjenmonk

Hey :)

You dont need configure the template_folder param, because, we will make this for you

https://github.com/marcuxyz/mvc_flask/blob/0c9a463a0744ff6ca072ac2eb5cf89bd25d0504d/mvc_flask/init.py#L14

Please, see this image:

image

is your directory like this?

marcuxyz avatar Sep 06 '21 00:09 marcuxyz

yes, the folder structure is like that. I removed the template_folder='views' and now it is working. not sure why. but thanks for your time

bjenmonk avatar Sep 06 '21 00:09 bjenmonk

You are welcome! :)

marcuxyz avatar Sep 06 '21 00:09 marcuxyz

Actually, its not working still have same problem.

nand2509 avatar Apr 27 '22 05:04 nand2509

app = Flask(name) instead of this only you can write as mentioned below.

app = Flask(name, template_folder='templates')
//here templates is the folder name , check your folder name and write it inside single quotes. this one worked for me.

Sandesh-Ghimire avatar Dec 26 '22 11:12 Sandesh-Ghimire

yes, the folder structure is like that. I removed the template_folder='views' and now it is working. not sure why. but thanks for your time

please shared this repository, i will go review

marcuxyz avatar Dec 26 '22 13:12 marcuxyz

Hi there! To solve TEMPLATE NOT FOUND ERROR in Flask I added "template_folder". So in short you get this:

from flask import Flask, render_template

app=Flask(__name__, template_folder='template')

@app.route('/')
def main():
    return render_template('home.html')

app.run(debug=True)

kssy-ks avatar Mar 23 '23 18:03 kssy-ks

Hi there! To solve TEMPLATE NOT FOUND ERROR in Flask I added "template_folder". So in short you get this:

from flask import Flask, render_template

app=Flask(__name__, template_folder='template')

@app.route('/')
def main():
    return render_template('home.html')

app.run(debug=True)

Hi @kssy-ks . Fines? please shared this repository, i will go review.

marcuxyz avatar Mar 26 '23 19:03 marcuxyz

I tested here, its work for me :) see:

Captura de Tela 2023-04-05 às 23 23 12

marcuxyz avatar Apr 06 '23 02:04 marcuxyz

Sorry to say but this bug is really annoying. I tried all the suggested solutions but still face the same issue

Reins981 avatar Aug 17 '23 13:08 Reins981

Sorry to say but this bug is really annoying. I tried all the suggested solutions but still face the same issue

Can you share this repository?

marcuxyz avatar Aug 19 '23 08:08 marcuxyz

app = Flask(name) instead of this only you can write as mentioned below.

app = Flask(name, template_folder='templates') //here templates is the folder name , check your folder name and write it inside single quotes. this one worked for me.

i try for a hour ....it works for me!!!!!!!!!!! thanks a lot

eyobmamo avatar Aug 29 '23 19:08 eyobmamo

People, if you don't to describe the issue, it's hard to understand!!!!!

PLEASE, SEND YOUR PROJECT TO GITHUB AND SHARE FOR ME

if your project isn't open source, please, create one and share.

marcuxyz avatar Aug 30 '23 19:08 marcuxyz

image

Hello @marcuxyz , I also facing the same issue can you please help me with this.

ajanujaj avatar Dec 07 '23 06:12 ajanujaj

Hello @ajanujaj , It looks like it doesn't use the mvc-flask extension

marcuxyz avatar Dec 07 '23 08:12 marcuxyz

📦app ┣ 📂resources ┃ ┣ 📂static ┃ ┃ ┣ 📂css ┃ ┃ ┃ ┣ 📜login.css ┃ ┃ ┃ ┣ 📜register.css ┃ ┃ ┃ ┗ 📜style.css ┃ ┃ ┣ 📂img ┃ ┃ ┗ 📂js ┃ ┃ ┃ ┣ 📜app.js ┃ ┃ ┃ ┣ 📜login.js ┃ ┃ ┃ ┗ 📜register.js ┃ ┗ 📂templates ┃ ┃ ┣ 📜about.html ┃ ┃ ┣ 📜index.html ┃ ┃ ┣ 📜login.html ┃ ┃ ┣ 📜register.html ┃ ┃ ┗ 📜services.html ┣ 📂__pycache__ ┃ ┣ 📜app.cpython-312.pyc ┃ ┣ 📜model.cpython-312.pyc ┃ ┣ 📜routes.cpython-312.pyc ┃ ┗ 📜__init__.cpython-312.pyc ┣ 📜app.py ┣ 📜model.py ┣ 📜routes.py ┗ 📜__init__.py

Cobalah mas ireng! in routes.py ->

               app = Flask(__name__, static_folder='resources/static', template_folder='resources/templates')

in html ->

             <link rel="stylesheet" href="{{ url_for('static', filename='css/login.css') }}"> 

             <script src="{{ url_for('static', filename='js/login.js') }}"></script>

MuhamadZaki avatar Feb 25 '24 19:02 MuhamadZaki

Hi I having the same issue on mine . @marcuxyz can you help me
440420548_1453720012020229_5253463462240928238_n 440523839_458919010032819_8051616861470120693_n 440441369_409729901835646_629505621840532910_n

iankb26 avatar May 01 '24 15:05 iankb26

@iankb26 you can send code to github and send me the link? Did you leave the code structure the same as this image? https://github.com/marcuxyz/mvc-flask/issues/9#issuecomment-1498403553

marcuxyz avatar May 02 '24 00:05 marcuxyz

@marcuxyz https://github.com/iankb26/User-Interface Here's the link let me know what you think and I'm trying to use mvc method like what you showed on the previcus comments. Thanks for the help marcus :) ,

iankb26 avatar May 02 '24 12:05 iankb26

@iankb26 Have you sent the correct code? I have not found the mvc-flask library.

marcuxyz avatar May 04 '24 11:05 marcuxyz

I also have the same problem, can someone help me? https://github.com/thanhhungk57/Mongodb-connect-fastapi.git

thanhhungk57 avatar May 08 '24 03:05 thanhhungk57

@thanhhungk57 this project uses the fastapi project. mvc-flask only works on Flask. https://flask.palletsprojects.com/

marcuxyz avatar May 09 '24 20:05 marcuxyz

hi @marcuxyz

i am also facing the same issue i have tried everything using template folder variable changing the name of the folder but facing the same issue Screenshot (7) Screenshot (8)

supreetbajaj2004 avatar Jul 21 '24 02:07 supreetbajaj2004

Hi @supreetbajaj2004 , Have you installed and used the extension: MVC-flask? In your images, it looks like that doesn't. Please visit the documentation https://marcuxyz.github.io/mvc-flask/

marcuxyz avatar Jul 21 '24 17:07 marcuxyz

I will thanks for help@marcuxyz

supreetbajaj2004 avatar Jul 21 '24 17:07 supreetbajaj2004

Such a long discussion for a simple bug. Why is that

Reins981 avatar Jul 21 '24 17:07 Reins981