# myproject/settings.py LOGIN_REDIRECT_URL = 'home' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' http://127.0.0.1:8000/login/ http://127.0.0.1:8000/signup/ http://127.0.0.1:8000/reset/ http://127.0.0.1:8000/reset/done/ http://127.…
# myproject/settings.py LOGOUT_REDIRECT_URL = 'home' http://127.0.0.1:8000/logout/ # myproject/urls.py from django.conf.urls import url from django.contrib import admin from django.contrib.auth import views as auth_views from accounts import views as…
http://127.0.0.1:8000/boards/1/topics/1/ #boards/views.py @login_required def new_topic(request, pk): board = get_object_or_404(Board, pk=pk) if request.method == 'POST': form = NewTopicForm(request.POST) if form.is_valid(): topic = form.save(commit=…
http://127.0.0.1:8000/boards/1/topics/62/reply/ 我觉得只添加内置的个性化(humanize)包就会很不错. 它包含一组为数据添加“人性化(human touch)”的工具集. 例如,我们可以使用它来更自然地显示日期和时间字段. 我们可以简单地显示:“2分钟前”,而不是显示整个日期. 首先,添加 django.contrib.humanize 到配置文件的INSTALLED_APPS 中. #myproject/settings.py INSTALL…
http://127.0.0.1:8000/boards/1/ http://127.0.0.1:8000/boards/2/ http://127.0.0.1:8000/boards/3/ http://127.0.0.1:8000/boards/1/new/http://127.0.0.1:8000/boards/2/new/ http://127.0.0.1:8000/boards/3/new/ 这是我们在前一个教程绘制的线框图.我现在意识到这个可能是一个不好的例子,因为这个特殊的表单涉及…
http://127.0.0.1:8000/boards/1/topics/102/reply/ 让我们在文本区域添加 Markdown 支持来改善用户体验. 你会看到要实现这个功能非常简单. 首先,我们安装一个名为 Python-Markdown 的库: pip install markdown #我们可以在 Post 视图的 model 中添加一个新的⽅法: #boards/models.py from django.db import models from django.utils.ht…
http://127.0.0.1:8000/boards/1/topics/2/posts/2/edit/ http://127.0.0.1:8000/ #boards/views.py from django.views.generic import UpdateView from django.utils import timezone class PostUpdateView(UpdateView): model = Post fields = ('message', ) template…
#1.编写一个程序,询问用户要租赁什么样的汽车,并打印. car = input("What's kind of cars dou you want to rent?,sir:") print('Let me see if I can find you a '+ car) print('\n') #2.编写一个程序,询问用户有多少人用餐.如果超过8人,就打印一条消息,指出没有空桌:否则指出有空桌 table = input("尊敬的先生/女士,请问订餐人数是多少?:"…
http://127.0.0.1:8000/signup/ django-admin startapp accounts INSTALLED_APPS = [ 'accounts', ] # myproject/urls.py from django.conf.urls import url from django.contrib import admin from accounts import views as accounts_views from boards import views…
http://127.0.0.1:8000/http://127.0.0.1:8000/boards/1/http://127.0.0.1:8000/boards/2/http://127.0.0.1:8000/boards/3/ <!--static/css/app.css--> .navbar-brand { font-family: 'Peralta', cursive; } <!--templates/base.html--> {% load static %}<!D…