Django入门与实践-第17章:保护视图(完结)
#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> {% csrf_token %} <input type="hidden" name="next" value="{{ next }}"> {% include 'includes/form.html' %} <button type="submit" class="btn btn-primary btn-block">Login</button> </form>