Django入门问题
python3.6 django2.2.1
1.显示特定主题页面
描述:Could not parse the remainder: ‘: ‘M d, Y H:i’’ from ‘entry.date_added|date: ‘M d, Y H:i’’
原代码
1
2 {% extends 'learning_logs/base.html' %}
3
4 {% block content %}
5 <p>Topic : {{ topic }}</p>
6
7 <p>Entries</p>
8 <ul>
9 {% for entry in entries %}
10 <li>
11 <p>{{ entry.date_added|date: 'M d, Y H:i' }}</p>
12 <p>{{ entry.text|linebreaks }}</p>
13 </li>
14 {% empty %}
15 <li>
16 There are no entries for this topic yet.
17 </li>
18 {% endfor %}
19 </ul>
20
21 {% endblock content %}
删除此行代码即可,但删除后页面无法显示具体时间
<p>{{ entry.date_added|date: 'M d, Y H:i' }}</p>
2.登陆页面问题
描述:用户名,密码没错,点击下方“log in”按钮没有反应,
检查:
python manage.py runserver
命令下运行没有问题,代码无错误。
解决: 网上搜索到了这个项目的源码,更换了之后就解决了。
源码链接:https://github.com/bastamon/Python-Crash-Course/tree/master/chapter_19
3. gitignore文件在一开始提交文件时忽略不了
原代码:
11_env/
__pycache__/
*.sqlite3
解决:在上面代码前加“/”
/11_env/
/__pycache__/
*.sqlite3
注意:当已经把全部的文件都提交完后才发现gitignore文件没有起作用,则可以用以下代码:
git rm -r --cached . #清楚缓存
git commit -m "update .gitignore" #更新文件
git add . #重新提交