Part 4 - Authentication(14-16)
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 accounts_views
from boards import views urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^signup/$', accounts_views.signup, name='signup'),
url(r'^login/$', auth_views.LoginView.as_view(template_name='login.html'), name='login'),
url(r'^logout/$', auth_views.LogoutView.as_view(), name='logout'), url(r'^reset/$',
auth_views.PasswordResetView.as_view(
template_name='password_reset.html',
email_template_name='password_reset_email.html',
subject_template_name='password_reset_subject.txt'
),
name='password_reset'),
url(r'^reset/done/$',
auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'),
name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'),
name='password_reset_confirm'),
url(r'^reset/complete/$',
auth_views.PasswordResetCompleteView.as_view(template_name='password_reset_complete.html'),
name='password_reset_complete'), url(r'^settings/password/$', auth_views.PasswordChangeView.as_view(template_name='password_change.html'),
name='password_change'),
url(r'^settings/password/done/$', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'),
name='password_change_done'), url(r'^boards/(?P<pk>\d+)/$', views.board_topics, name='board_topics'),
url(r'^boards/(?P<pk>\d+)/new/$', views.new_topic, name='new_topic'),
url(r'^admin/', admin.site.urls),
]
python manage.py makemigrations
python manage.py sqlmigrate boards 0001
python manage.py migrate python manage.py shell from boards.models import Board
board = Board.objects.create(name='Django', description='This is a board about Django.')
board = Board.objects.create(name='Python', description='General discussion about Python.')
board = Board.objects.create(name='Random', description='Here you can discuss about anything.') boards_list = Board.objects.all()
for board in boards_list:
print(board.description)
#accounts/forms.py
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User class SignUpForm(UserCreationForm):
email = forms.CharField(max_length=254, required=True, widget=forms.EmailInput()) class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2')
#boards/templatetags/form_tags.py
from django import template register = template.Library() @register.filter
def field_type(bound_field):
return bound_field.field.widget.__class__.__name__ @register.filter
def input_class(bound_field):
css_class = ''
if bound_field.form.is_bound:
if bound_field.errors:
css_class = 'is-invalid'
elif field_type(bound_field) != 'PasswordInput':
css_class = 'is-valid'
return 'form-control {}'.format(css_class)
Part 4 - Authentication(14-16)的更多相关文章
- (2.16)Mysql之SQL基础——函数
(2.16)Mysql之SQL基础——函数 关键词:mysql函数,mysql自定义函数,mysql聚合函数,mysql字符串函数,mysql数值函数 1.自定义函数 -- (1)一般形式 creat ...
- (Problem 16)Power digit sum
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of th ...
- (1.16)mysql server优化之buffer pool
(1.16)mysql server优化之buffer pool 1.innodb buffer pool 查看 show status like 'Innodb_buffer_pool_%'; 该 ...
- (3.16)mysql基础深入——mysql字符集
(3.16)mysql基础深入——mysql字符集 关键字:mysql字符集,mysql编码 目录 1.概念 2.常用的字符编码 3.查看mysql字符集 [3.1]查看服务器支持的字符集 [3.2] ...
- 【每日Scrum】第六天(4.16) TD学生助手Sprint1阶段性成果
TD学生助手Sprint1阶段性成果(4.16) 任务看板 站立会议内容 组员 昨天 今天 困难 签到 刘铸辉 (组长) 和叶姐,静姐修改页面布局和图片显示,保证界面的亲切. 和大家一起做演示PPT, ...
- SQL Server2012 T-SQL基础教程--读书笔记(1-4章)
SQL Server2012 T-SQL基础教程--读书笔记(1-4章) SqlServer T-SQL 示例数据库:点我 Chapter 01 T-SQL 查询和编程背景 1.3 创建表和定义数据的 ...
- (4)Linux命令分类汇总(13~16)
Linux命令分类汇总(13~16) (十三)系统管理与性能监视命令(9个) 79 chkconfig 管理Linux系统开机启动项. 80 vmstat 虚拟内存统计. 81 ...
- Http authentication(BASIC, DIGEST)
Http authentication....BASIC: In the context of an HTTP transaction, basic access authentication is ...
- (4.16)sql server迁移DB文件(同一DB内)
SQL Server 修改数据库物理文件存在位置 关键词:迁移文件,迁移temp库(这怎么迁移呢,用方法2即可,需要重启实例) 三种均需要离线: 一共分为(1)脱机迁移和(2)在线迁移. (1)迁移方 ...
- Kubuntu(14.04)共享wifi(热点)
笔记本(kubuntu14.04)通过有线上网,共享本机无线给手机.平板及其他通过wifi上网的设备. 曾经在网上找过各种方法.下载了非常多软件都不能在本机上实现wifi共享,以下这样的方法眼下相对简 ...
随机推荐
- java msgbox
JAVA import javax.swing.JOptionPane; JOptionPane.showMessageDialog( null,"sample dialog !" ...
- J2SE 8的输入输出--Path/Paths File/Files; FileSystems 类的用法
Path的简单用法 //1. Path 正常用法 Path path = Paths.get("src/main/resource/zip"); logger.debug(path ...
- div 标签
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 17 网络编程 C/S架构介绍
1.什么是C/S架构 C指的是client(客户端软件),S指的是Server(服务器软件),本章的重点是教大家写一个C/S架构的软件,实现服务端软件与客户端软件基于网络通信. 2.计算机基础的知识- ...
- MVC控制器详解
原文地址:http://www.cnblogs.com/SeeYouBug/p/6441934.html#3628606 目录 一.理解控制器 1.1.什么是控制器 1.2.控制器的作用 1.3.创建 ...
- Producer-consumer problem in Python
from: http://agiliq.com/blog/2013/10/producer-consumer-problem-in-python/ By : Akshar Raaj We will s ...
- 事件委托,js中的一种优化方法
在前端编程中,我们常会遇到一种叫做事件委托的方法. 那么, 什么是事件委托呢? 简单来说,事件就是指onclick,onmouseover,onmouseout等大部分事件,为什么说是大部分后面会提到 ...
- cvc-complex-type.2.3: Element 'beans' cannot have character [children]
当启动spring的项目时,有时候会抛如下异常: Line 33 in XML document from ServletContext resource [/WEB-INF/backend-serv ...
- drupal 7.1 doc
https://www.drupal.org/docs/8/api/database-api/dynamic-queries/count-queries https://www.drupal.org/ ...
- dubbo hessian+dubbo协议
Dubbo缺省协议采用单一长连接和NIO异步通讯,适合于小数据量大并发的服务调用,以及服务消费者机器数远大于服务提供者机器数的情况 Hessian协议用于集成Hessian的服务,Hessian底层采 ...