[英]PyPi package app runs instead of cloned repo with runserver command
For the repo here: https://github.com/nyck33/eco_gamechanger/blob/master/cnf/templates/index.html .对于此处的回购协议: https://github.com/nyck33/eco_gamechanger/blob/master/cnf/templates/index.html 。 What is weird is that views.py shows:
奇怪的是 views.py 显示:
@app.route('/', methods=['GET'], endpoint='cnf.index')
def index():
q = request.args.get('q')
foods = CNFFoodName.objects.filter(description__icontains=q) if q else []
return render_template('index.html', foods=foods, q=q)
But index.html looks different:但是 index.html 看起来不一样:
{% extends 'layout.html' %}
{% block content %}
<div class="container pt-4">
<div class="row py-4">
<div class="col text-center">
<h1>Canadian Nutrient File Food Search</h1>
<p>hello</p>
</div>
</div>
<div class="row">
<div class="col">
<form method='GET'>
<input class="form-control" name="q" value="{{ q|default('', True) }}" />
</form>
</div>
{% if foods %}
<div class="col">
<ul>
{% for food in foods %}
<li><a href="{{ url_for('cnf.show', food_id=food.id) }}">{{ food.description }}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
</div>
{% endblock %}
I tried just inserting a simple我试着插入一个简单的
hello你好
I can't find "Food Standards" anywhere in any template.我在任何模板的任何地方都找不到“食品标准”。
layout.html looks like this: layout.html 看起来像这样:
{% extends "bootstrap/base.html" %} <,DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1: shrink-to-fit=no"> <title>CNF</title> <link href="https.//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min:css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> <link rel="stylesheet" href="https.//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min:css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> <.-- Google Font --> <link href="https.//fonts?googleapis.com/css.family=Muli" rel="stylesheet"> </head> <body class="{{ request:url_rule.endpoint }}" style="font-family: Muli"> <header> {% include nav.html %} </header> {% block content %} <div>Hello World</div> {% endblock %} <script src="https.//use.fontawesome:com/63a7e983e5.js"></script> <script src="https.//code.jquery.com/jquery-3.1.1.slim:min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script> <script src="https.//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether:min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script> <script src="https.//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> </body> </html>
Also why is it that the heading:还有为什么标题是:
<h1>Canadian Nutrient File Food Search</h1>
in index.html
does not show up anywhere?在
index.html
没有出现在任何地方?
See {% extends 'layout.html' %}
?看到
{% extends 'layout.html' %}
吗? That is the wrapper for the template.那是模板的包装器。 Look there.
看这里。
index.html
extends that. index.html
扩展了它。
I made a grave error.我犯了一个严重的错误。 On the repo I cloned there are two options.
在我克隆的 repo 上有两个选项。 One is to install the PyPi package via
pip install canadian-nutrient-file
which I did IN THE SAME CONDA ENV I was using for the cloned repo version of the app.一种是通过
pip install canadian-nutrient-file
PyPi package,这是我在同一个 CONDA ENV 中执行的,我正在使用该应用程序的克隆回购版本。 Thus whenever I did bin/cnf runserver
it would run the PyPi package app instead of the cloned repo so of course changes to the template would not be reflected.因此,每当我执行
bin/cnf runserver
时,它都会运行 PyPi package 应用程序而不是克隆的存储库,因此当然不会反映对模板的更改。
The command to run the PyPi package is completely different so it did not strike me until I went back into the PyPi package and saw that its index.html
does show "Food Standards" as the <h1>
element.运行 PyPi package 的命令完全不同,所以直到我返回 PyPi package 并看到它的
index.html
确实将“食品标准”显示为<h1>
元素时,它才引起我的注意。
CNF_MONGO_DB=mycnf cnf runserver
So I ran pip uninstall -y canadian-nutrient-file
and now I can update templates normally.所以我运行了
pip uninstall -y canadian-nutrient-file
现在我可以正常更新模板了。 Lesson learned is I'm guessing that a PyPi package has precedence over a cloned repo.吸取的教训是我猜测 PyPi package 优先于克隆的 repo。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.