我正在尝试为我的数据库创建一个填充脚本,但我收到一个 No module named 错误。
Project Structure:
staticone/
manage.py
mysite/
populate_rango
settings
urls
__init__
wsgi
rango/
Run Code Online (Sandbox Code Playgroud)
追溯:
Traceback (most recent call last):
File "populate_rango.py", line 8, in <module>
django.setup()
File "/home/ubuntu/virtenv/webstatic/lib/python3.5/site-
packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ubuntu/virtenv/webstatic/lib/python3.5/site-
packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/ubuntu/virtenv/webstatic/lib/python3.5/site-
packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in …Run Code Online (Sandbox Code Playgroud) 我在 django 模板中收到以下错误消息:第 10 行未封闭的标记:“if”。寻找其中之一:endif。
我在第 20 行使用 endif 来关闭 if 类别。如果页面在第 16 行关闭。不确定这是否是语法问题?
<!DOCTYPE html>
<html>
<head>
<title>Rango</title>
</head>
<body>
<div>
{% if category %}
{{ category.name }}
<ul>
{% if pages %}
{% for page in pages %}
<li> {{ page.title }} </li>
{% endfor %}
</ul>
{% else %}
<strong>No Pages</strong>
{% endif %}
{% else %}
<strong>The specified category does not exist!</strong>
<% endif %}
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
在for循环中:counter <(x.lenght)拼写错误,但函数返回零.当更正为x.length时,函数返回正确的B数,3.1)为什么返回零?2)为什么javascript没有捕获到这个错误?3)对于未来,我可以采取哪些措施来确保捕获这些类型的错误?
function countBs(x){
var lCounter = 0;
for (var counter = 0; counter < (x.lenght); counter++){
if((x.charAt(counter)) == "B"){
lCounter++;
}
}
return lCounter;
}
console.log(countBs("BCBDB"));
Run Code Online (Sandbox Code Playgroud)