file gets unresolved warning when trying to extend to html file

626 views Asked by At

I'm trying to use flask-bootstrap in my project and I want to extend my html with bootstrap/base.html , but It can't recognise the file. Here is the Python code (only the part that matters):

from flask import Flask, render_template
from loggin_form import LoggingForm
from flask_bootstrap import Bootstrap

app = Flask(__name__)
app.secret_key = "123string"
Bootstrap(app)

and here is the html:

{% extends "bootstrap/base.html" %}
{% block title %}This is an example page{% endblock %}

{% block navbar %}
<div class="navbar navbar-fixed-top">
    something
</div>
{% endblock %}

{% block content %}
  <h1>something else</h1>
{% endblock %}

I have tried many things, but not much seems to work. as you can see I have correctly passe the app inside the bootstrap class (it's usually the solution that people with similar problems found) but I already have done it. Also I have correctly installed Flask-Bootstrap and the path directory of bootstrap/base.html is as followed : venv/lib/python3.10/site-packages/flask_bootstrap/templates/bootstrap/base.html

the exact warning that pycharm throws at me: Unresolved template reference '"bootstrap/base.html"'

it does that even if I put the full path directory.

I thank you in advance for your answers guys.

Ps: I am using jinja 2.11.3 and Flask 1.1.4

2

There are 2 answers

0
younes alaoui On

I found out that the folder inside the venv where the base.html was had to marked as a template folder. Then Pycharm easily recognised it

0
owen douglas On

You need to mark the flask-bootstrap templates folder as a template folder.

In Settings, go to Project Structure and navigate to venv/lib/site-packages/flask_bootstrap. Right-click on the templates folder and mark it as Templates. Apply this and it should work.