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/ 这是我们在前一个教程绘制的线框图.我现在意识到这个可能是一个不好的例子,因为这个特殊的表单涉及…
# 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.…
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/boards/1/ #boards/views.py from django.contrib.auth.decorators import login_required @login_required def new_topic(request, pk): <!--配置登录后的重定向地址--> <!----templates/login.html--> <form method="post" novalidate…
http://127.0.0.1:8000/boards/1/ python manage.py migrate #boards/models.py class Topic(models.Model): views = models.PositiveIntegerField(default=0) # <- here python manage.py makemigrations python manage.py migrate #boards/views.py def topic_posts(r…
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…
http://127.0.0.1:8000/boards/1/topics/1/reply/ http://127.0.0.1:8000/boards/1/topics/1/ #myproject/urls.py url(r'^boards/(?P<pk>\d+)/topics/(?P<topic_pk>\d+)/reply/$',views.reply_topic, name='reply_topic'), #boards/forms.py from .models import…
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/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…
http://127.0.0.1:8000http://127.0.0.1:8000/boards/1/http://127.0.0.1:8000/boards/2/http://127.0.0.1:8000/boards/3/ # myproject/urls.py from django.conf.urls import url from django.contrib import admin from boards import views urlpatterns = [ url(r'^$…